goby-database 2.2.22 → 2.2.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -604,7 +604,8 @@ export default class Project {
604
604
  // creates table
605
605
  this.create_table('junction', id, [
606
606
  `"${junction_col_name(sides[0].class_id, sides[0].prop_id)}" INTEGER`,
607
- `"${junction_col_name(sides[1].class_id, sides[1].prop_id)}" INTEGER`
607
+ `"${junction_col_name(sides[1].class_id, sides[1].prop_id)}" INTEGER`,
608
+ `date_added INTEGER`
608
609
  ]);
609
610
  return id;
610
611
  }
@@ -782,11 +783,12 @@ export default class Project {
782
783
  input_2: junction_col_name(input_2.class_id, input_2.prop_id)
783
784
  };
784
785
  let junction_id = (_a = this.junction_cache.find(j => full_relation_match(j.sides, [input_1, input_2]))) === null || _a === void 0 ? void 0 : _a.id;
786
+ const date_added = Date.now();
785
787
  if (junction_id) {
786
788
  this.db.prepare(`
787
789
  INSERT INTO junction_${junction_id}
788
- ("${column_names.input_1}", "${column_names.input_2}")
789
- VALUES (${input_1.item_id},${input_2.item_id})
790
+ ("${column_names.input_1}", "${column_names.input_2}",date_added)
791
+ VALUES (${input_1.item_id},${input_2.item_id},${date_added})
790
792
  `).run();
791
793
  }
792
794
  else {
@@ -837,7 +839,7 @@ export default class Project {
837
839
  let target_select = `
838
840
  SELECT
839
841
  "${property_junction_column_name}",
840
- json_object('class_id',${target.class_id},'system_id',junction."${target_junction_column_name}"${label_sql_string}) AS target_data
842
+ json_object('class_id',${target.class_id},'system_id',junction."${target_junction_column_name}"${label_sql_string}) AS target_data, junction.date_added AS date_added
841
843
  FROM junction_${junction_id} AS junction
842
844
  LEFT JOIN "class_${target_class === null || target_class === void 0 ? void 0 : target_class.name}" AS target_class ON junction."${target_junction_column_name}" = target_class.system_id
843
845
  `;
@@ -855,8 +857,10 @@ export default class Project {
855
857
  ${target_selects.join(`
856
858
  UNION
857
859
  `)}
860
+ ORDER BY date_added
858
861
  )
859
862
  GROUP BY "${property_junction_column_name}"
863
+
860
864
  )`;
861
865
  cte_strings.push(cte);
862
866
  relation_selections.push(`[${prop.id}_cte].[user_${prop.name}]`);
package/dist/types.d.ts CHANGED
@@ -23,8 +23,10 @@ export type RelationTarget = {
23
23
  prop_id?: number | null;
24
24
  junction_id: number;
25
25
  };
26
- export type ItemRelationSide = RelationshipSide & {
26
+ export type ItemRelationSide = {
27
+ class_id: number;
27
28
  item_id: number;
29
+ prop_id?: number;
28
30
  };
29
31
  type RelationCreate = {
30
32
  type: 'create';
@@ -130,6 +132,7 @@ export type PropertyDefinition = {
130
132
  } | DataDefinition);
131
133
  export type ClassRow = {
132
134
  [key: string]: any;
135
+ system_id: number;
133
136
  };
134
137
  export type ClassData = {
135
138
  id: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goby-database",
3
- "version": "2.2.22",
3
+ "version": "2.2.24",
4
4
  "description": "This will hold the core better-sqlite3-powered application for creating and modifying goby databases",
5
5
  "main": "dist/index.js",
6
6
  "files": [