sedentary-pg 0.0.42 → 0.0.45

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/README.md CHANGED
@@ -42,7 +42,7 @@ const db = new SedentaryPG(/* PG connection */);
42
42
 
43
43
  class Items extends db.model("Item", {
44
44
  num: db.INT,
45
- str: db.VARCHAR(30)
45
+ str: db.VarChar(30)
46
46
  });
47
47
 
48
48
  (async function () {
@@ -91,9 +91,9 @@ To work with the package under Windows, be sure to configure `bash.exe` as your
91
91
  > npm config set script-shell bash.exe
92
92
  ```
93
93
 
94
- # Licence
94
+ # License
95
95
 
96
- [MIT Licence](https://github.com/iccicci/sedentary-pg/blob/master/LICENSE)
96
+ [MIT License](https://github.com/iccicci/sedentary-pg/blob/master/LICENSE)
97
97
 
98
98
  # Bugs
99
99
 
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Package = exports.SedentaryPG = exports.TransactionPG = exports.Type = exports.EntryBase = void 0;
3
+ exports.SedentaryPG = exports.TransactionPG = exports.Type = exports.EntryBase = void 0;
4
4
  const sedentary_1 = require("sedentary");
5
5
  const pgdb_1 = require("./pgdb");
6
6
  var sedentary_2 = require("sedentary");
@@ -15,18 +15,17 @@ class SedentaryPG extends sedentary_1.Sedentary {
15
15
  throw new Error("SedentaryPG.constructor: 'connection' argument: Wrong type, expected 'Object'");
16
16
  this.db = new pgdb_1.PGDB(connection, this.log);
17
17
  }
18
- FKEY(attribute, options) {
18
+ FKey(attribute, options) {
19
19
  const { attributeName, modelName, unique } = attribute;
20
20
  if (!unique)
21
- throw new Error(`Sedentary.FKEY: '${modelName}' model: '${attributeName}' attribute: is not unique: can't be used as FKEY target`);
22
- return super.FKEY(attribute, options);
21
+ throw new Error(`SedentaryPG.FKey: '${modelName}' model: '${attributeName}' attribute: is not unique: can't be used as FKey target`);
22
+ return super.FKey(attribute, options);
23
23
  }
24
- async begin() {
24
+ begin() {
25
25
  return this.db.begin();
26
26
  }
27
- async client() {
27
+ client() {
28
28
  return this.db.client();
29
29
  }
30
30
  }
31
31
  exports.SedentaryPG = SedentaryPG;
32
- exports.Package = SedentaryPG;
package/dist/cjs/pgdb.js CHANGED
@@ -12,17 +12,27 @@ const needDrop = [
12
12
  ["DATETIME", "int2"],
13
13
  ["DATETIME", "int4"],
14
14
  ["DATETIME", "int8"],
15
+ ["DATETIME", "numeric"],
16
+ ["INT", "json"],
15
17
  ["INT", "timestamptz"],
16
- ["INT8", "timestamptz"]
18
+ ["INT8", "json"],
19
+ ["INT8", "timestamptz"],
20
+ ["JSON", "int2"],
21
+ ["JSON", "int4"],
22
+ ["JSON", "int8"],
23
+ ["JSON", "numeric"],
24
+ ["NUMBER", "json"],
25
+ ["NUMBER", "timestamptz"]
17
26
  ];
18
27
  const needUsing = [
19
28
  ["BOOLEAN", "varchar"],
20
29
  ["DATETIME", "varchar"],
21
30
  ["INT", "varchar"],
22
31
  ["INT8", "varchar"],
32
+ ["JSON", "varchar"],
23
33
  ["NUMBER", "varchar"]
24
34
  ];
25
- const types = { bool: "BOOL", int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", numeric: "NUMERIC", timestamptz: "DATETIME", varchar: "VARCHAR" };
35
+ const types = { bool: "BOOL", int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", json: "JSON", numeric: "NUMERIC", timestamptz: "DATETIME", varchar: "VARCHAR" };
26
36
  const actions = { cascade: "c", "no action": "a", restrict: "r", "set default": "d", "set null": "n" };
27
37
  function parseInt8(value) {
28
38
  return BigInt(value);
@@ -63,16 +73,31 @@ class PGDB extends sedentary_1.DB {
63
73
  await ret._client.query("BEGIN");
64
74
  return ret;
65
75
  }
76
+ cancel(tableName) {
77
+ return async (where, tx) => {
78
+ const client = tx ? tx._client : await this.pool.connect();
79
+ let rowCount = 0;
80
+ try {
81
+ const query = `DELETE FROM ${tableName}${where ? ` WHERE ${where}` : ""}`;
82
+ this.log(query);
83
+ ({ rowCount } = await client.query(query));
84
+ }
85
+ finally {
86
+ if (!tx)
87
+ client.release();
88
+ }
89
+ return rowCount;
90
+ };
91
+ }
66
92
  async client() {
67
93
  return await this.pool.connect();
68
94
  }
69
95
  escape(value) {
70
96
  if (value === null || value === undefined)
71
97
  throw new Error("SedentaryPG: Can't escape null nor undefined values; use the 'IS NULL' operator instead");
72
- const type = typeof value;
73
- if (type === "number" || type === "boolean")
98
+ if (typeof value === "boolean" || typeof value === "number")
74
99
  return value.toString();
75
- if (type === "string")
100
+ if (typeof value === "string")
76
101
  return (0, pg_format_1.default)("%L", value);
77
102
  //if(value instanceof Date)
78
103
  return (0, pg_format_1.default)("%L", value).replace(/\.\d\d\d\+/, "+");
@@ -132,13 +157,13 @@ class PGDB extends sedentary_1.DB {
132
157
  remove(tableName, pk) {
133
158
  // eslint-disable-next-line @typescript-eslint/no-this-alias
134
159
  const self = this;
135
- const pkAttrnName = pk.attributeName;
160
+ const pkAttrName = pk.attributeName;
136
161
  const pkFldName = pk.fieldName;
137
162
  return async function () {
138
163
  const client = this.tx ? this.tx._client : await self.pool.connect();
139
164
  let removed = false;
140
165
  try {
141
- const query = `DELETE FROM ${tableName} WHERE ${pkFldName} = ${self.escape(this[pkAttrnName])}`;
166
+ const query = `DELETE FROM ${tableName} WHERE ${pkFldName} = ${self.escape(this[pkAttrName])}`;
142
167
  self.log(query);
143
168
  removed = (await client.query(query)).rowCount === 1;
144
169
  }
@@ -152,7 +177,7 @@ class PGDB extends sedentary_1.DB {
152
177
  save(tableName, attributes, pk) {
153
178
  // eslint-disable-next-line @typescript-eslint/no-this-alias
154
179
  const self = this;
155
- const pkAttrnName = pk.attributeName;
180
+ const pkAttrName = pk.attributeName;
156
181
  const pkFldName = pk.fieldName;
157
182
  return async function () {
158
183
  const client = this.tx ? this.tx._client : await self.pool.connect();
@@ -167,7 +192,7 @@ class PGDB extends sedentary_1.DB {
167
192
  actions.push(`${attributes[attribute]} = ${self.escape(value)}`);
168
193
  }
169
194
  if (actions.length) {
170
- const query = `UPDATE ${tableName} SET ${actions.join(", ")} WHERE ${pkFldName} = ${self.escape(this[pkAttrnName])}`;
195
+ const query = `UPDATE ${tableName} SET ${actions.join(", ")} WHERE ${pkFldName} = ${self.escape(this[pkAttrName])}`;
171
196
  self.log(query);
172
197
  self.fill(attributes, (await client.query(query + " RETURNING *")).rows[0], this);
173
198
  changed = true;
@@ -234,26 +259,26 @@ class PGDB extends sedentary_1.DB {
234
259
  }
235
260
  async dropIndexes(table, constraintIndexes) {
236
261
  const { indexes, oid } = table;
237
- const iobject = {};
262
+ const iObject = {};
238
263
  const res = await this._client.query("SELECT amname, attname, indexrelid, indisunique, relname FROM pg_class, pg_index, pg_attribute, pg_am WHERE indrelid = $1 AND indexrelid = pg_class.oid AND attrelid = pg_class.oid AND relam = pg_am.oid ORDER BY attnum", [oid]);
239
264
  for (const row of res.rows) {
240
265
  const { amname, attname, indexrelid, indisunique, relname } = row;
241
266
  if (!constraintIndexes.includes(indexrelid)) {
242
- if (iobject[relname])
243
- iobject[relname].fields.push(attname);
267
+ if (iObject[relname])
268
+ iObject[relname].fields.push(attname);
244
269
  else
245
- iobject[relname] = { fields: [attname], indexName: relname, type: amname, unique: indisunique };
270
+ iObject[relname] = { fields: [attname], indexName: relname, type: amname, unique: indisunique };
246
271
  }
247
272
  }
248
273
  this.indexes = [];
249
274
  for (const index of indexes) {
250
275
  const { indexName } = index;
251
- if (iobject[indexName] && this.indexesEq(index, iobject[indexName])) {
276
+ if (iObject[indexName] && this.indexesEq(index, iObject[indexName])) {
252
277
  this.indexes.push(indexName);
253
- delete iobject[indexName];
278
+ delete iObject[indexName];
254
279
  }
255
280
  }
256
- for (const index of Object.keys(iobject).sort()) {
281
+ for (const index of Object.keys(iObject).sort()) {
257
282
  const statement = `DROP INDEX ${index}`;
258
283
  this.syncLog(statement);
259
284
  if (this.sync)
@@ -306,13 +331,15 @@ class PGDB extends sedentary_1.DB {
306
331
  return ["BOOL", "BOOL"];
307
332
  case "DATETIME":
308
333
  return ["DATETIME", "TIMESTAMP (3) WITH TIME ZONE"];
309
- case "NUMBER":
310
- return ["NUMERIC", "NUMERIC"];
311
334
  case "INT":
312
335
  ret = size === 2 ? "SMALLINT" : "INTEGER";
313
336
  return [ret, ret];
314
337
  case "INT8":
315
338
  return ["BIGINT", "BIGINT"];
339
+ case "JSON":
340
+ return ["JSON", "JSON"];
341
+ case "NUMBER":
342
+ return ["NUMERIC", "NUMERIC"];
316
343
  case "VARCHAR":
317
344
  return ["VARCHAR", "VARCHAR" + (size ? `(${size})` : "")];
318
345
  }
@@ -368,7 +395,7 @@ class PGDB extends sedentary_1.DB {
368
395
  else {
369
396
  const { adsrc, attnotnull, atttypmod, typname } = res.rows[0];
370
397
  if (types[typname] !== base || (base === "VARCHAR" && (size ? size + 4 !== atttypmod : atttypmod !== -1))) {
371
- if (needDrop.filter(([type, name]) => attribute.type === type && typname === name).length) {
398
+ if (needDrop.some(([type, name]) => attribute.type === type && typname === name)) {
372
399
  await this.dropField(tableName, fieldName);
373
400
  await addField();
374
401
  await setDefault(false);
@@ -376,7 +403,7 @@ class PGDB extends sedentary_1.DB {
376
403
  else {
377
404
  if (adsrc)
378
405
  dropDefault();
379
- const using = needUsing.filter(([type, name]) => attribute.type === type && typname === name).length ? " USING " + fieldName + "::" + type : "";
406
+ const using = needUsing.some(([type, name]) => attribute.type === type && typname === name) ? " USING " + fieldName + "::" + type : "";
380
407
  const statement = `ALTER TABLE ${tableName} ALTER COLUMN ${fieldName} TYPE ${type}${using}`;
381
408
  this.syncLog(statement);
382
409
  if (this.sync)
package/dist/es/index.js CHANGED
@@ -9,17 +9,16 @@ export class SedentaryPG extends Sedentary {
9
9
  throw new Error("SedentaryPG.constructor: 'connection' argument: Wrong type, expected 'Object'");
10
10
  this.db = new PGDB(connection, this.log);
11
11
  }
12
- FKEY(attribute, options) {
12
+ FKey(attribute, options) {
13
13
  const { attributeName, modelName, unique } = attribute;
14
14
  if (!unique)
15
- throw new Error(`Sedentary.FKEY: '${modelName}' model: '${attributeName}' attribute: is not unique: can't be used as FKEY target`);
16
- return super.FKEY(attribute, options);
15
+ throw new Error(`SedentaryPG.FKey: '${modelName}' model: '${attributeName}' attribute: is not unique: can't be used as FKey target`);
16
+ return super.FKey(attribute, options);
17
17
  }
18
- async begin() {
18
+ begin() {
19
19
  return this.db.begin();
20
20
  }
21
- async client() {
21
+ client() {
22
22
  return this.db.client();
23
23
  }
24
24
  }
25
- export const Package = SedentaryPG;
package/dist/es/pgdb.js CHANGED
@@ -6,17 +6,27 @@ const needDrop = [
6
6
  ["DATETIME", "int2"],
7
7
  ["DATETIME", "int4"],
8
8
  ["DATETIME", "int8"],
9
+ ["DATETIME", "numeric"],
10
+ ["INT", "json"],
9
11
  ["INT", "timestamptz"],
10
- ["INT8", "timestamptz"]
12
+ ["INT8", "json"],
13
+ ["INT8", "timestamptz"],
14
+ ["JSON", "int2"],
15
+ ["JSON", "int4"],
16
+ ["JSON", "int8"],
17
+ ["JSON", "numeric"],
18
+ ["NUMBER", "json"],
19
+ ["NUMBER", "timestamptz"]
11
20
  ];
12
21
  const needUsing = [
13
22
  ["BOOLEAN", "varchar"],
14
23
  ["DATETIME", "varchar"],
15
24
  ["INT", "varchar"],
16
25
  ["INT8", "varchar"],
26
+ ["JSON", "varchar"],
17
27
  ["NUMBER", "varchar"]
18
28
  ];
19
- const types = { bool: "BOOL", int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", numeric: "NUMERIC", timestamptz: "DATETIME", varchar: "VARCHAR" };
29
+ const types = { bool: "BOOL", int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", json: "JSON", numeric: "NUMERIC", timestamptz: "DATETIME", varchar: "VARCHAR" };
20
30
  const actions = { cascade: "c", "no action": "a", restrict: "r", "set default": "d", "set null": "n" };
21
31
  function parseInt8(value) {
22
32
  return BigInt(value);
@@ -58,16 +68,31 @@ export class PGDB extends DB {
58
68
  await ret._client.query("BEGIN");
59
69
  return ret;
60
70
  }
71
+ cancel(tableName) {
72
+ return async (where, tx) => {
73
+ const client = tx ? tx._client : await this.pool.connect();
74
+ let rowCount = 0;
75
+ try {
76
+ const query = `DELETE FROM ${tableName}${where ? ` WHERE ${where}` : ""}`;
77
+ this.log(query);
78
+ ({ rowCount } = await client.query(query));
79
+ }
80
+ finally {
81
+ if (!tx)
82
+ client.release();
83
+ }
84
+ return rowCount;
85
+ };
86
+ }
61
87
  async client() {
62
88
  return await this.pool.connect();
63
89
  }
64
90
  escape(value) {
65
91
  if (value === null || value === undefined)
66
92
  throw new Error("SedentaryPG: Can't escape null nor undefined values; use the 'IS NULL' operator instead");
67
- const type = typeof value;
68
- if (type === "number" || type === "boolean")
93
+ if (typeof value === "boolean" || typeof value === "number")
69
94
  return value.toString();
70
- if (type === "string")
95
+ if (typeof value === "string")
71
96
  return format("%L", value);
72
97
  //if(value instanceof Date)
73
98
  return format("%L", value).replace(/\.\d\d\d\+/, "+");
@@ -127,13 +152,13 @@ export class PGDB extends DB {
127
152
  remove(tableName, pk) {
128
153
  // eslint-disable-next-line @typescript-eslint/no-this-alias
129
154
  const self = this;
130
- const pkAttrnName = pk.attributeName;
155
+ const pkAttrName = pk.attributeName;
131
156
  const pkFldName = pk.fieldName;
132
157
  return async function () {
133
158
  const client = this.tx ? this.tx._client : await self.pool.connect();
134
159
  let removed = false;
135
160
  try {
136
- const query = `DELETE FROM ${tableName} WHERE ${pkFldName} = ${self.escape(this[pkAttrnName])}`;
161
+ const query = `DELETE FROM ${tableName} WHERE ${pkFldName} = ${self.escape(this[pkAttrName])}`;
137
162
  self.log(query);
138
163
  removed = (await client.query(query)).rowCount === 1;
139
164
  }
@@ -147,7 +172,7 @@ export class PGDB extends DB {
147
172
  save(tableName, attributes, pk) {
148
173
  // eslint-disable-next-line @typescript-eslint/no-this-alias
149
174
  const self = this;
150
- const pkAttrnName = pk.attributeName;
175
+ const pkAttrName = pk.attributeName;
151
176
  const pkFldName = pk.fieldName;
152
177
  return async function () {
153
178
  const client = this.tx ? this.tx._client : await self.pool.connect();
@@ -162,7 +187,7 @@ export class PGDB extends DB {
162
187
  actions.push(`${attributes[attribute]} = ${self.escape(value)}`);
163
188
  }
164
189
  if (actions.length) {
165
- const query = `UPDATE ${tableName} SET ${actions.join(", ")} WHERE ${pkFldName} = ${self.escape(this[pkAttrnName])}`;
190
+ const query = `UPDATE ${tableName} SET ${actions.join(", ")} WHERE ${pkFldName} = ${self.escape(this[pkAttrName])}`;
166
191
  self.log(query);
167
192
  self.fill(attributes, (await client.query(query + " RETURNING *")).rows[0], this);
168
193
  changed = true;
@@ -229,26 +254,26 @@ export class PGDB extends DB {
229
254
  }
230
255
  async dropIndexes(table, constraintIndexes) {
231
256
  const { indexes, oid } = table;
232
- const iobject = {};
257
+ const iObject = {};
233
258
  const res = await this._client.query("SELECT amname, attname, indexrelid, indisunique, relname FROM pg_class, pg_index, pg_attribute, pg_am WHERE indrelid = $1 AND indexrelid = pg_class.oid AND attrelid = pg_class.oid AND relam = pg_am.oid ORDER BY attnum", [oid]);
234
259
  for (const row of res.rows) {
235
260
  const { amname, attname, indexrelid, indisunique, relname } = row;
236
261
  if (!constraintIndexes.includes(indexrelid)) {
237
- if (iobject[relname])
238
- iobject[relname].fields.push(attname);
262
+ if (iObject[relname])
263
+ iObject[relname].fields.push(attname);
239
264
  else
240
- iobject[relname] = { fields: [attname], indexName: relname, type: amname, unique: indisunique };
265
+ iObject[relname] = { fields: [attname], indexName: relname, type: amname, unique: indisunique };
241
266
  }
242
267
  }
243
268
  this.indexes = [];
244
269
  for (const index of indexes) {
245
270
  const { indexName } = index;
246
- if (iobject[indexName] && this.indexesEq(index, iobject[indexName])) {
271
+ if (iObject[indexName] && this.indexesEq(index, iObject[indexName])) {
247
272
  this.indexes.push(indexName);
248
- delete iobject[indexName];
273
+ delete iObject[indexName];
249
274
  }
250
275
  }
251
- for (const index of Object.keys(iobject).sort()) {
276
+ for (const index of Object.keys(iObject).sort()) {
252
277
  const statement = `DROP INDEX ${index}`;
253
278
  this.syncLog(statement);
254
279
  if (this.sync)
@@ -301,13 +326,15 @@ export class PGDB extends DB {
301
326
  return ["BOOL", "BOOL"];
302
327
  case "DATETIME":
303
328
  return ["DATETIME", "TIMESTAMP (3) WITH TIME ZONE"];
304
- case "NUMBER":
305
- return ["NUMERIC", "NUMERIC"];
306
329
  case "INT":
307
330
  ret = size === 2 ? "SMALLINT" : "INTEGER";
308
331
  return [ret, ret];
309
332
  case "INT8":
310
333
  return ["BIGINT", "BIGINT"];
334
+ case "JSON":
335
+ return ["JSON", "JSON"];
336
+ case "NUMBER":
337
+ return ["NUMERIC", "NUMERIC"];
311
338
  case "VARCHAR":
312
339
  return ["VARCHAR", "VARCHAR" + (size ? `(${size})` : "")];
313
340
  }
@@ -363,7 +390,7 @@ export class PGDB extends DB {
363
390
  else {
364
391
  const { adsrc, attnotnull, atttypmod, typname } = res.rows[0];
365
392
  if (types[typname] !== base || (base === "VARCHAR" && (size ? size + 4 !== atttypmod : atttypmod !== -1))) {
366
- if (needDrop.filter(([type, name]) => attribute.type === type && typname === name).length) {
393
+ if (needDrop.some(([type, name]) => attribute.type === type && typname === name)) {
367
394
  await this.dropField(tableName, fieldName);
368
395
  await addField();
369
396
  await setDefault(false);
@@ -371,7 +398,7 @@ export class PGDB extends DB {
371
398
  else {
372
399
  if (adsrc)
373
400
  dropDefault();
374
- const using = needUsing.filter(([type, name]) => attribute.type === type && typname === name).length ? " USING " + fieldName + "::" + type : "";
401
+ const using = needUsing.some(([type, name]) => attribute.type === type && typname === name) ? " USING " + fieldName + "::" + type : "";
375
402
  const statement = `ALTER TABLE ${tableName} ALTER COLUMN ${fieldName} TYPE ${type}${using}`;
376
403
  this.syncLog(statement);
377
404
  if (this.sync)
@@ -1,12 +1,11 @@
1
- import { Attribute, EntryBase, ForeignKeyOptions, Natural, Sedentary, SedentaryOptions, Type } from "sedentary";
1
+ import { Attribute, EntryBase, ForeignKeyOptions, Sedentary, SedentaryOptions, Type } from "sedentary";
2
2
  import { PoolConfig } from "pg";
3
3
  import { PGDB, TransactionPG } from "./pgdb";
4
4
  export { Entry, EntryBase, SedentaryOptions, Type } from "sedentary";
5
5
  export { TransactionPG } from "./pgdb";
6
6
  export declare class SedentaryPG extends Sedentary<PGDB, TransactionPG> {
7
7
  constructor(connection: PoolConfig, options?: SedentaryOptions);
8
- FKEY<N extends Natural, E extends EntryBase>(attribute: Attribute<N, E>, options?: ForeignKeyOptions): Type<N, E>;
8
+ FKey<T, E extends EntryBase>(attribute: Attribute<T, E>, options?: ForeignKeyOptions): Type<T, E>;
9
9
  begin(): Promise<TransactionPG>;
10
10
  client(): Promise<import("pg").PoolClient>;
11
11
  }
12
- export declare const Package: typeof SedentaryPG;
@@ -1,5 +1,5 @@
1
1
  import { PoolClient, PoolConfig } from "pg";
2
- import { Attribute, DB, EntryBase, Natural, Table, Transaction } from "sedentary";
2
+ import { Attribute, DB, EntryBase, Table, Transaction } from "sedentary";
3
3
  export declare class PGDB extends DB<TransactionPG> {
4
4
  private _client;
5
5
  private indexes;
@@ -10,16 +10,17 @@ export declare class PGDB extends DB<TransactionPG> {
10
10
  constructor(connection: PoolConfig, log: (message: string) => void);
11
11
  connect(): Promise<void>;
12
12
  end(): Promise<void>;
13
- defaultNeq(src: string, value: Natural): boolean;
13
+ defaultNeq(src: string, value: unknown): boolean;
14
14
  begin(): Promise<TransactionPG>;
15
+ cancel(tableName: string): (where: string, tx?: Transaction) => Promise<number>;
15
16
  client(): Promise<PoolClient>;
16
- escape(value: Natural): string;
17
- fill(attributes: Record<string, string>, row: Record<string, Natural>, entry: Record<string, Natural>): void;
18
- load(tableName: string, attributes: Record<string, string>, pk: Attribute<Natural, unknown>, model: new (from: "load") => EntryBase, table: Table): (where: string, order?: string | string[], limit?: number, tx?: Transaction) => Promise<EntryBase[]>;
19
- remove(tableName: string, pk: Attribute<Natural, unknown>): (this: Record<string, Natural> & {
17
+ escape(value: unknown): string;
18
+ fill(attributes: Record<string, string>, row: Record<string, unknown>, entry: Record<string, unknown>): void;
19
+ load(tableName: string, attributes: Record<string, string>, pk: Attribute<unknown, unknown>, model: new (from: "load") => EntryBase, table: Table): (where: string, order?: string | string[], limit?: number, tx?: Transaction) => Promise<EntryBase[]>;
20
+ remove(tableName: string, pk: Attribute<unknown, unknown>): (this: Record<string, unknown> & {
20
21
  tx?: TransactionPG;
21
22
  }) => Promise<boolean>;
22
- save(tableName: string, attributes: Record<string, string>, pk: Attribute<Natural, unknown>): (this: Record<string, Natural> & {
23
+ save(tableName: string, attributes: Record<string, string>, pk: Attribute<unknown, unknown>): (this: Record<string, unknown> & {
23
24
  loaded?: Record<string, unknown>;
24
25
  tx?: TransactionPG;
25
26
  }) => Promise<boolean>;
@@ -29,7 +30,7 @@ export declare class PGDB extends DB<TransactionPG> {
29
30
  dropIndexes(table: Table, constraintIndexes: number[]): Promise<void>;
30
31
  syncConstraints(table: Table): Promise<void>;
31
32
  syncDataBase(): Promise<void>;
32
- fieldType(attribute: Attribute<Natural, unknown>): string[];
33
+ fieldType(attribute: Attribute<unknown, unknown>): string[];
33
34
  syncFields(table: Table): Promise<void>;
34
35
  syncIndexes(table: Table): Promise<void>;
35
36
  syncSequence(table: Table): Promise<void>;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "@types/pg": "8.6.5",
10
10
  "pg": "8.7.3",
11
11
  "pg-format": "1.0.4",
12
- "sedentary": "0.0.42"
12
+ "sedentary": "0.0.45"
13
13
  },
14
14
  "description": "The ORM which never needs to migrate - PostgreSQL",
15
15
  "engines": {
@@ -39,13 +39,13 @@
39
39
  "repository": "https://github.com/iccicci/sedentary",
40
40
  "scripts": {
41
41
  "build": "make build",
42
- "coverage": "jest --coverage --runInBand",
43
- "deploy": "npm_config_registry=\"registry.npmjs.org\" npm publish",
42
+ "coverage": "jest --coverage --no-cache --runInBand",
43
+ "deploy": "make deploy",
44
44
  "precoverage": "make pretest",
45
45
  "preinstall": "if [ -f Makefile ] ; then make ; fi",
46
46
  "pretest": "make pretest",
47
- "test": "jest --runInBand"
47
+ "test": "jest --no-cache --runInBand"
48
48
  },
49
49
  "types": "./dist/types/index.d.ts",
50
- "version": "0.0.42"
50
+ "version": "0.0.45"
51
51
  }