tabletcommand-backend-models 5.18.7 → 5.18.8
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.
|
@@ -55,6 +55,17 @@ async function AssignmentModule(mongoose) {
|
|
|
55
55
|
collection: "massive_assignment",
|
|
56
56
|
});
|
|
57
57
|
modelSchema.set("autoIndex", false);
|
|
58
|
+
modelSchema.set("toJSON", {
|
|
59
|
+
virtuals: true,
|
|
60
|
+
versionKey: false,
|
|
61
|
+
transform(doc, ret) {
|
|
62
|
+
ret.id = ret._id;
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
modelSchema.virtual("id").get(function () {
|
|
66
|
+
// tslint:disable-next-line: no-unsafe-any
|
|
67
|
+
return this._id.toString();
|
|
68
|
+
});
|
|
58
69
|
return (0, helpers_1.createModel)(mongoose, "Assignment", modelSchema);
|
|
59
70
|
}
|
|
60
71
|
exports.AssignmentModule = AssignmentModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignment.js","sourceRoot":"","sources":["../../src/models/assignment.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAE7B,
|
|
1
|
+
{"version":3,"file":"assignment.js","sourceRoot":"","sources":["../../src/models/assignment.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAE7B,wCAYoB;AAEb,KAAK,UAAU,gBAAgB,CAAC,QAAwB;IAC7D,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC;IAEnC,MAAM,WAAW,GAAG,IAAA,sBAAY,EAAC,MAAM,EAAE;QACvC,GAAG,EAAE;YACH,IAAI,EAAE,KAAK,CAAC,QAAQ;YACpB,IAAI,EAAE,IAAI;SACX;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,CAAC;SACX;QACD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,IAAI,CAA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<reference types="mongoose" />
|
|
2
|
-
import {
|
|
2
|
+
import { ItemTypeFromTypeSchemaFunction, ModelTypeFromTypeSchemaFunction, MongooseModule, ReplaceModelReturnType } from "../helpers";
|
|
3
3
|
export declare function AssignmentModule(mongoose: MongooseModule): Promise<import("mongoose").Model<import("mongoose").Document & Record<string, unknown> & {
|
|
4
4
|
_id: import("bson").ObjectID;
|
|
5
5
|
position: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignment.d.ts","sourceRoot":"","sources":["../../src/models/assignment.ts"],"names":[],"mappings":";AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"assignment.d.ts","sourceRoot":"","sources":["../../src/models/assignment.ts"],"names":[],"mappings":";AAEA,OAAO,EAKL,8BAA8B,EAE9B,+BAA+B,EAE/B,cAAc,EACd,sBAAsB,EAEvB,MAAM,YAAY,CAAC;AAEpB,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,cAAc;;;;;;;;;;;;;;;GAmE9D;AAED,MAAM,WAAW,UAAW,SAAQ,8BAA8B,CAAC,OAAO,gBAAgB,CAAC;CAAI;AAC/F,MAAM,WAAW,eAAgB,SAAQ,+BAA+B,CAAC,UAAU,CAAC;CAAI;;AACxF,wBAAoG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tabletcommand-backend-models",
|
|
3
|
-
"version": "5.18.
|
|
3
|
+
"version": "5.18.8",
|
|
4
4
|
"description": "Tablet Command Backend Models",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "gulp",
|
|
@@ -26,24 +26,24 @@
|
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/bluebird": "^3.5.36",
|
|
29
|
-
"@types/chai": "^4.3.
|
|
30
|
-
"@types/lodash": "^4.14.
|
|
31
|
-
"@types/mocha": "^9.1.
|
|
29
|
+
"@types/chai": "^4.3.1",
|
|
30
|
+
"@types/lodash": "^4.14.182",
|
|
31
|
+
"@types/mocha": "^9.1.1",
|
|
32
32
|
"@types/mongodb": "^3.6.20",
|
|
33
33
|
"@types/mongoose": "~5.10.5",
|
|
34
34
|
"@types/uuid": "~8.3.4",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "~5.
|
|
36
|
-
"@typescript-eslint/parser": "~5.
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "~5.25.0",
|
|
36
|
+
"@typescript-eslint/parser": "~5.25.0",
|
|
37
37
|
"chai": "^4.3.6",
|
|
38
|
-
"del": "^6.
|
|
39
|
-
"eslint": "^8.
|
|
38
|
+
"del": "^6.1.0",
|
|
39
|
+
"eslint": "^8.16.0",
|
|
40
40
|
"gulp": "^4.0.2",
|
|
41
41
|
"gulp-mocha": "^8.0.0",
|
|
42
42
|
"gulp-shell": "^0.8.0",
|
|
43
43
|
"mocha": "^9.2.2",
|
|
44
|
-
"ts-node": "^10.
|
|
44
|
+
"ts-node": "^10.8.0",
|
|
45
45
|
"type-coverage": "^2.21.1",
|
|
46
|
-
"typescript": "^4.6.
|
|
46
|
+
"typescript": "^4.6.4",
|
|
47
47
|
"yargs-parser": ">=21.0.1"
|
|
48
48
|
},
|
|
49
49
|
"typeCoverage": {
|
package/src/models/assignment.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import * as uuid from "uuid";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
MongooseModule,
|
|
5
|
-
createSchema,
|
|
6
4
|
createModel,
|
|
5
|
+
createSchema,
|
|
7
6
|
currentDate,
|
|
8
|
-
|
|
9
|
-
ModelTypeFromTypeSchemaFunction,
|
|
7
|
+
DocumentTypeFromSchema,
|
|
10
8
|
ItemTypeFromTypeSchemaFunction,
|
|
9
|
+
ModelFromSchema,
|
|
10
|
+
ModelTypeFromTypeSchemaFunction,
|
|
11
|
+
MongooseDocument,
|
|
12
|
+
MongooseModule,
|
|
11
13
|
ReplaceModelReturnType,
|
|
14
|
+
retrieveCurrentUnixTime,
|
|
12
15
|
} from "../helpers";
|
|
13
16
|
|
|
14
17
|
export async function AssignmentModule(mongoose: MongooseModule) {
|
|
@@ -64,6 +67,19 @@ export async function AssignmentModule(mongoose: MongooseModule) {
|
|
|
64
67
|
collection: "massive_assignment",
|
|
65
68
|
});
|
|
66
69
|
modelSchema.set("autoIndex", false);
|
|
70
|
+
modelSchema.set("toJSON", {
|
|
71
|
+
virtuals: true,
|
|
72
|
+
versionKey: false,
|
|
73
|
+
transform(doc: ModelFromSchema<typeof modelSchema>, ret: DocumentTypeFromSchema<typeof modelSchema>) {
|
|
74
|
+
ret.id = ret._id;
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
modelSchema.virtual("id").get(function(this: MongooseDocument) {
|
|
79
|
+
// tslint:disable-next-line: no-unsafe-any
|
|
80
|
+
return this._id.toString();
|
|
81
|
+
});
|
|
82
|
+
|
|
67
83
|
return createModel(mongoose, "Assignment", modelSchema);
|
|
68
84
|
}
|
|
69
85
|
|
package/test/assignment.js
CHANGED
|
@@ -22,22 +22,21 @@ describe("Assignment", function() {
|
|
|
22
22
|
mongoose.disconnect();
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
it("is saved", function(
|
|
26
|
-
|
|
27
|
-
item.save(
|
|
28
|
-
assert.isNull(err, "Should not err");
|
|
25
|
+
it("is saved", async function() {
|
|
26
|
+
const item = new models.Assignment(testItem);
|
|
27
|
+
const sut = await item.save();
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
assert.isNotNull(testItem._id);
|
|
30
|
+
assert.equal(sut._id.toString(), sut.id.toString());
|
|
31
|
+
|
|
32
|
+
assert.equal(testItem.position, sut.position);
|
|
33
|
+
assert.equal(testItem.active, sut.active);
|
|
34
|
+
assert.equal(testItem.name, sut.name);
|
|
35
|
+
assert.equal(testItem.userId, sut.userId);
|
|
36
|
+
assert.equal(testItem.departmentId, sut.departmentId);
|
|
37
|
+
assert.equal(testItem.isMandatory, sut.isMandatory);
|
|
38
|
+
const expectedDate = new Date().valueOf() / 1000.0;
|
|
39
|
+
const timeDelta = expectedDate - sut.modified_unix_date;
|
|
40
|
+
assert.isTrue(timeDelta < 1);
|
|
42
41
|
});
|
|
43
42
|
});
|