@naturalcycles/datastore-lib 3.20.1 → 3.21.0
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/datastore.db.js +2 -1
- package/dist/query.util.js +2 -1
- package/package.json +3 -3
- package/src/datastore.db.ts +5 -2
- package/src/query.util.ts +2 -1
package/dist/datastore.db.js
CHANGED
|
@@ -303,7 +303,8 @@ class DatastoreDB extends db_lib_1.BaseCommonDB {
|
|
|
303
303
|
stats
|
|
304
304
|
.filter(s => !s.property_name.includes('.') && s.property_name !== 'id') // filter out objectify's "virtual properties"
|
|
305
305
|
.forEach(stats => {
|
|
306
|
-
const {
|
|
306
|
+
const { property_type: dtype } = stats;
|
|
307
|
+
const name = stats.property_name;
|
|
307
308
|
if (dtype === datastore_model_1.DatastoreType.Blob) {
|
|
308
309
|
s.properties[name] = {
|
|
309
310
|
instanceof: 'Buffer',
|
package/dist/query.util.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dbQueryToDatastoreQuery = void 0;
|
|
4
|
-
// import Operator = google.datastore.v1.CompositeFilter.Operator
|
|
5
4
|
const FNAME_MAP = {
|
|
6
5
|
id: '__key__',
|
|
7
6
|
};
|
|
8
7
|
const OP_MAP = {
|
|
9
8
|
'==': '=',
|
|
9
|
+
in: 'IN',
|
|
10
|
+
'not-in': 'NOT_IN',
|
|
10
11
|
};
|
|
11
12
|
function dbQueryToDatastoreQuery(dbQuery, emptyQuery) {
|
|
12
13
|
let q = emptyQuery;
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/datastore-lib",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.0",
|
|
4
4
|
"description": "Opinionated library to work with Google Datastore",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepare": "husky install"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@google-cloud/datastore": "^
|
|
9
|
+
"@google-cloud/datastore": "^7.0.0",
|
|
10
10
|
"@naturalcycles/db-lib": "^8.0.0",
|
|
11
11
|
"@naturalcycles/js-lib": "^14.0.0",
|
|
12
12
|
"@naturalcycles/nodejs-lib": "^12.0.0",
|
|
13
13
|
"grpc": "^1.24.2"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@naturalcycles/dev-lib": "^
|
|
16
|
+
"@naturalcycles/dev-lib": "^13.0.0",
|
|
17
17
|
"@types/node": "^17.0.8",
|
|
18
18
|
"jest": "^28.1.0"
|
|
19
19
|
},
|
package/src/datastore.db.ts
CHANGED
|
@@ -448,7 +448,8 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
|
|
|
448
448
|
stats
|
|
449
449
|
.filter(s => !s.property_name.includes('.') && s.property_name !== 'id') // filter out objectify's "virtual properties"
|
|
450
450
|
.forEach(stats => {
|
|
451
|
-
const {
|
|
451
|
+
const { property_type: dtype } = stats
|
|
452
|
+
const name = stats.property_name as keyof ROW
|
|
452
453
|
|
|
453
454
|
if (dtype === DatastoreType.Blob) {
|
|
454
455
|
s.properties[name] = {
|
|
@@ -488,7 +489,9 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
|
|
|
488
489
|
} as JsonSchemaNull
|
|
489
490
|
}
|
|
490
491
|
} else {
|
|
491
|
-
throw new Error(
|
|
492
|
+
throw new Error(
|
|
493
|
+
`Unknown Datastore Type '${stats.property_type}' for ${table}.${name as string}`,
|
|
494
|
+
)
|
|
492
495
|
}
|
|
493
496
|
})
|
|
494
497
|
|
package/src/query.util.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Query } from '@google-cloud/datastore'
|
|
2
2
|
import { DBQuery, DBQueryFilterOperator } from '@naturalcycles/db-lib'
|
|
3
3
|
import { ObjectWithId, StringMap } from '@naturalcycles/js-lib'
|
|
4
|
-
// import Operator = google.datastore.v1.CompositeFilter.Operator
|
|
5
4
|
|
|
6
5
|
const FNAME_MAP: StringMap = {
|
|
7
6
|
id: '__key__',
|
|
@@ -9,6 +8,8 @@ const FNAME_MAP: StringMap = {
|
|
|
9
8
|
|
|
10
9
|
const OP_MAP: Partial<Record<DBQueryFilterOperator, string>> = {
|
|
11
10
|
'==': '=',
|
|
11
|
+
in: 'IN',
|
|
12
|
+
'not-in': 'NOT_IN',
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export function dbQueryToDatastoreQuery<ROW extends ObjectWithId>(
|