@steedos/objectql 2.2.33 → 2.2.36
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/lib/driver/driver.d.ts +1 -0
- package/lib/driver/format.d.ts +15 -0
- package/lib/driver/format.js +31 -0
- package/lib/driver/format.js.map +1 -0
- package/lib/driver/index.d.ts +1 -0
- package/lib/driver/index.js +1 -0
- package/lib/driver/index.js.map +1 -1
- package/lib/driver/meteorMongo.d.ts +2 -1
- package/lib/driver/meteorMongo.js +4 -0
- package/lib/driver/meteorMongo.js.map +1 -1
- package/lib/driver/mongo.d.ts +2 -2
- package/lib/driver/mongo.js +4 -19
- package/lib/driver/mongo.js.map +1 -1
- package/lib/dynamic-load/actions.js +1 -0
- package/lib/dynamic-load/actions.js.map +1 -1
- package/lib/dynamic-load/package.js +1 -0
- package/lib/dynamic-load/package.js.map +1 -1
- package/lib/types/datasource.d.ts +1 -0
- package/lib/types/datasource.js +3 -0
- package/lib/types/datasource.js.map +1 -1
- package/lib/types/object.d.ts +1 -0
- package/lib/types/object.js +25 -6
- package/lib/types/object.js.map +1 -1
- package/package.json +9 -9
- package/src/driver/driver.ts +3 -2
- package/src/driver/format.ts +36 -0
- package/src/driver/index.ts +4 -3
- package/src/driver/meteorMongo.ts +6 -1
- package/src/driver/mongo.ts +5 -20
- package/src/dynamic-load/actions.ts +1 -0
- package/src/dynamic-load/package.ts +1 -0
- package/src/types/datasource.ts +4 -0
- package/src/types/object.ts +14 -0
package/src/types/datasource.ts
CHANGED
|
@@ -394,6 +394,10 @@ export class SteedosDataSourceType implements Dictionary {
|
|
|
394
394
|
return await this._adapter.delete(tableName, id, userId)
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
+
formatRecord(doc: Dictionary<any>, objectConfig: SteedosObjectType) {
|
|
398
|
+
return this._adapter.formatRecord(doc, objectConfig)
|
|
399
|
+
}
|
|
400
|
+
|
|
397
401
|
async count(tableName: string, query: SteedosQueryOptions, userId?: SteedosIDType) {
|
|
398
402
|
return await this._adapter.count(tableName, query, userId)
|
|
399
403
|
}
|
package/src/types/object.ts
CHANGED
|
@@ -854,22 +854,26 @@ export class SteedosObjectType extends SteedosObjectProperties {
|
|
|
854
854
|
}
|
|
855
855
|
|
|
856
856
|
async insert(doc: Dictionary<any>, userSession?: SteedosUserSession) {
|
|
857
|
+
doc = this.formatRecord(doc);
|
|
857
858
|
return await this.callAdapter('insert', this.table_name, doc, userSession)
|
|
858
859
|
}
|
|
859
860
|
|
|
860
861
|
async update(id: SteedosIDType, doc: Dictionary<any>, userSession?: SteedosUserSession) {
|
|
862
|
+
doc = this.formatRecord(doc);
|
|
861
863
|
await this.processUneditableFields(userSession, doc)
|
|
862
864
|
let clonedId = id;
|
|
863
865
|
return await this.callAdapter('update', this.table_name, clonedId, doc, userSession)
|
|
864
866
|
}
|
|
865
867
|
|
|
866
868
|
async updateOne(id: SteedosIDType, doc: Dictionary<any>, userSession?: SteedosUserSession) {
|
|
869
|
+
doc = this.formatRecord(doc);
|
|
867
870
|
await this.processUneditableFields(userSession, doc)
|
|
868
871
|
let clonedId = id;
|
|
869
872
|
return await this.callAdapter('updateOne', this.table_name, clonedId, doc, userSession)
|
|
870
873
|
}
|
|
871
874
|
// 此函数支持driver: MeteorMongo、Mongo
|
|
872
875
|
async updateMany(queryFilters: SteedosQueryFilters, doc: Dictionary<any>, userSession?: SteedosUserSession) {
|
|
876
|
+
doc = this.formatRecord(doc);
|
|
873
877
|
await this.processUneditableFields(userSession, doc)
|
|
874
878
|
let clonedQueryFilters = queryFilters;
|
|
875
879
|
return await this.callAdapter('updateMany', this.table_name, clonedQueryFilters, doc, userSession)
|
|
@@ -887,10 +891,12 @@ export class SteedosObjectType extends SteedosObjectProperties {
|
|
|
887
891
|
}
|
|
888
892
|
|
|
889
893
|
async directInsert(doc: Dictionary<any>, userSession?: SteedosUserSession) {
|
|
894
|
+
doc = this.formatRecord(doc);
|
|
890
895
|
return await this.callAdapter('directInsert', this.table_name, doc, userSession)
|
|
891
896
|
}
|
|
892
897
|
|
|
893
898
|
async directUpdate(id: SteedosIDType, doc: Dictionary<any>, userSession?: SteedosUserSession) {
|
|
899
|
+
doc = this.formatRecord(doc);
|
|
894
900
|
await this.processUneditableFields(userSession, doc)
|
|
895
901
|
let clonedId = id;
|
|
896
902
|
return await this.callAdapter('directUpdate', this.table_name, clonedId, doc, userSession)
|
|
@@ -1661,6 +1667,14 @@ export class SteedosObjectType extends SteedosObjectProperties {
|
|
|
1661
1667
|
// // })
|
|
1662
1668
|
}
|
|
1663
1669
|
|
|
1670
|
+
private formatRecord(doc: JsonMap) {
|
|
1671
|
+
let adapterFormat = this._datasource["formatRecord"];
|
|
1672
|
+
if (typeof adapterFormat == 'function') {
|
|
1673
|
+
doc = adapterFormat.apply(this._datasource, [doc, this.toConfig()]);
|
|
1674
|
+
}
|
|
1675
|
+
return doc;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1664
1678
|
private async callAdapter(method: string, ...args: any[]) {
|
|
1665
1679
|
|
|
1666
1680
|
const adapterMethod = this._datasource[method];
|