@bedrockio/model 0.1.32 → 0.2.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/README.md +323 -109
- package/dist/cjs/const.js +2 -4
- package/dist/cjs/delete-hooks.js +351 -0
- package/dist/cjs/disallowed.js +0 -14
- package/dist/cjs/env.js +1 -2
- package/dist/cjs/include.js +11 -3
- package/dist/cjs/query.js +21 -0
- package/dist/cjs/schema.js +6 -3
- package/dist/cjs/search.js +12 -23
- package/dist/cjs/serialization.js +5 -3
- package/dist/cjs/soft-delete.js +226 -51
- package/dist/cjs/validation.js +1 -2
- package/package.json +5 -5
- package/src/delete-hooks.js +343 -0
- package/src/disallowed.js +0 -29
- package/src/include.js +10 -1
- package/src/query.js +15 -0
- package/src/schema.js +9 -4
- package/src/search.js +15 -27
- package/src/serialization.js +5 -1
- package/src/soft-delete.js +248 -55
- package/types/delete-hooks.d.ts +2 -0
- package/types/delete-hooks.d.ts.map +1 -0
- package/types/disallowed.d.ts.map +1 -1
- package/types/load.d.ts +67 -1
- package/types/load.d.ts.map +1 -1
- package/types/query.d.ts +2 -0
- package/types/query.d.ts.map +1 -0
- package/types/schema.d.ts +15 -9
- package/types/schema.d.ts.map +1 -1
- package/types/search.d.ts.map +1 -1
- package/types/serialization.d.ts.map +1 -1
- package/types/soft-delete.d.ts.map +1 -1
- package/types/testing.d.ts +1 -1
- package/types/testing.d.ts.map +1 -1
- package/dist/cjs/references.js +0 -104
- package/src/references.js +0 -101
package/src/soft-delete.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { isEqual } from 'lodash';
|
|
2
|
+
|
|
3
|
+
import { wrapQuery } from './query';
|
|
4
|
+
|
|
1
5
|
export function applySoftDelete(schema) {
|
|
2
6
|
applyQueries(schema);
|
|
3
7
|
applyUniqueConstraints(schema);
|
|
8
|
+
applyHookPatch(schema);
|
|
4
9
|
}
|
|
5
10
|
|
|
6
11
|
// Soft Delete Querying
|
|
@@ -40,63 +45,84 @@ function applyQueries(schema) {
|
|
|
40
45
|
|
|
41
46
|
// Static Methods
|
|
42
47
|
|
|
43
|
-
schema.static('deleteOne',
|
|
48
|
+
schema.static('deleteOne', function deleteOne(filter, ...rest) {
|
|
44
49
|
const update = getDelete();
|
|
45
|
-
const
|
|
46
|
-
return {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
const query = this.updateOne(filter, update, ...omitCallback(rest));
|
|
51
|
+
return wrapQuery(query, async (promise) => {
|
|
52
|
+
const res = await promise;
|
|
53
|
+
return {
|
|
54
|
+
acknowledged: res.acknowledged,
|
|
55
|
+
deletedCount: res.modifiedCount,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
50
58
|
});
|
|
51
59
|
|
|
52
|
-
schema.static('deleteMany',
|
|
60
|
+
schema.static('deleteMany', function deleteMany(filter, ...rest) {
|
|
53
61
|
const update = getDelete();
|
|
54
|
-
const
|
|
55
|
-
return {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
const query = this.updateMany(filter, update, ...omitCallback(rest));
|
|
63
|
+
return wrapQuery(query, async (promise) => {
|
|
64
|
+
const res = await promise;
|
|
65
|
+
return {
|
|
66
|
+
acknowledged: res.acknowledged,
|
|
67
|
+
deletedCount: res.modifiedCount,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
59
70
|
});
|
|
60
71
|
|
|
61
|
-
schema.static(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return await this.findOneAndUpdate(filter, getDelete(), ...args);
|
|
65
|
-
}
|
|
66
|
-
);
|
|
72
|
+
schema.static('findOneAndDelete', function findOneAndDelete(filter, ...rest) {
|
|
73
|
+
return this.findOneAndUpdate(filter, getDelete(), ...omitCallback(rest));
|
|
74
|
+
});
|
|
67
75
|
|
|
68
|
-
schema.static('restoreOne',
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
schema.static('restoreOne', function restoreOne(filter, ...rest) {
|
|
77
|
+
const query = this.updateOne(filter, getRestore(), ...omitCallback(rest));
|
|
78
|
+
return wrapQuery(query, async (promise) => {
|
|
79
|
+
const res = await promise;
|
|
80
|
+
return {
|
|
81
|
+
acknowledged: res.acknowledged,
|
|
82
|
+
restoredCount: res.modifiedCount,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
75
85
|
});
|
|
76
86
|
|
|
77
|
-
schema.static('restoreMany',
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
schema.static('restoreMany', function restoreMany(filter, ...rest) {
|
|
88
|
+
const query = this.updateMany(filter, getRestore(), ...omitCallback(rest));
|
|
89
|
+
return wrapQuery(query, async (promise) => {
|
|
90
|
+
const res = await promise;
|
|
91
|
+
return {
|
|
92
|
+
acknowledged: res.acknowledged,
|
|
93
|
+
restoredCount: res.modifiedCount,
|
|
94
|
+
};
|
|
95
|
+
});
|
|
84
96
|
});
|
|
85
97
|
|
|
86
|
-
schema.static('destroyOne',
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
schema.static('destroyOne', function destroyOne(conditions, ...rest) {
|
|
99
|
+
// Following Mongoose patterns here
|
|
100
|
+
const query = new this.Query({}, {}, this, this.collection).deleteOne(
|
|
101
|
+
conditions,
|
|
102
|
+
...omitCallback(rest)
|
|
103
|
+
);
|
|
104
|
+
return wrapQuery(query, async (promise) => {
|
|
105
|
+
const res = await promise;
|
|
106
|
+
return {
|
|
107
|
+
acknowledged: res.acknowledged,
|
|
108
|
+
destroyedCount: res.deletedCount,
|
|
109
|
+
};
|
|
110
|
+
});
|
|
92
111
|
});
|
|
93
112
|
|
|
94
|
-
schema.static('destroyMany',
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
113
|
+
schema.static('destroyMany', function destroyMany(conditions, ...rest) {
|
|
114
|
+
// Following Mongoose patterns here
|
|
115
|
+
const query = new this.Query({}, {}, this, this.collection).deleteMany(
|
|
116
|
+
conditions,
|
|
117
|
+
...omitCallback(rest)
|
|
118
|
+
);
|
|
119
|
+
return wrapQuery(query, async (promise) => {
|
|
120
|
+
const res = await promise;
|
|
121
|
+
return {
|
|
122
|
+
acknowledged: res.acknowledged,
|
|
123
|
+
destroyedCount: res.deletedCount,
|
|
124
|
+
};
|
|
125
|
+
});
|
|
100
126
|
});
|
|
101
127
|
|
|
102
128
|
schema.static('findDeleted', function findDeleted(filter, ...rest) {
|
|
@@ -104,7 +130,7 @@ function applyQueries(schema) {
|
|
|
104
130
|
...filter,
|
|
105
131
|
deleted: true,
|
|
106
132
|
};
|
|
107
|
-
return this.find(filter, ...rest);
|
|
133
|
+
return this.find(filter, ...omitCallback(rest));
|
|
108
134
|
});
|
|
109
135
|
|
|
110
136
|
schema.static('findOneDeleted', function findOneDeleted(filter, ...rest) {
|
|
@@ -112,7 +138,7 @@ function applyQueries(schema) {
|
|
|
112
138
|
...filter,
|
|
113
139
|
deleted: true,
|
|
114
140
|
};
|
|
115
|
-
return this.findOne(filter, ...rest);
|
|
141
|
+
return this.findOne(filter, ...omitCallback(rest));
|
|
116
142
|
});
|
|
117
143
|
|
|
118
144
|
schema.static('findByIdDeleted', function findByIdDeleted(id, ...rest) {
|
|
@@ -120,7 +146,7 @@ function applyQueries(schema) {
|
|
|
120
146
|
_id: id,
|
|
121
147
|
deleted: true,
|
|
122
148
|
};
|
|
123
|
-
return this.findOne(filter, ...rest);
|
|
149
|
+
return this.findOne(filter, ...omitCallback(rest));
|
|
124
150
|
});
|
|
125
151
|
|
|
126
152
|
schema.static('existsDeleted', function existsDeleted(filter, ...rest) {
|
|
@@ -128,7 +154,7 @@ function applyQueries(schema) {
|
|
|
128
154
|
...filter,
|
|
129
155
|
deleted: true,
|
|
130
156
|
};
|
|
131
|
-
return this.exists(filter, ...rest);
|
|
157
|
+
return this.exists(filter, ...omitCallback(rest));
|
|
132
158
|
});
|
|
133
159
|
|
|
134
160
|
schema.static(
|
|
@@ -138,7 +164,7 @@ function applyQueries(schema) {
|
|
|
138
164
|
...filter,
|
|
139
165
|
deleted: true,
|
|
140
166
|
};
|
|
141
|
-
return this.countDocuments(filter, ...rest);
|
|
167
|
+
return this.countDocuments(filter, ...omitCallback(rest));
|
|
142
168
|
}
|
|
143
169
|
);
|
|
144
170
|
|
|
@@ -147,7 +173,7 @@ function applyQueries(schema) {
|
|
|
147
173
|
...filter,
|
|
148
174
|
...getWithDeletedQuery(),
|
|
149
175
|
};
|
|
150
|
-
return this.find(filter, ...rest);
|
|
176
|
+
return this.find(filter, ...omitCallback(rest));
|
|
151
177
|
});
|
|
152
178
|
|
|
153
179
|
schema.static(
|
|
@@ -157,7 +183,7 @@ function applyQueries(schema) {
|
|
|
157
183
|
...filter,
|
|
158
184
|
...getWithDeletedQuery(),
|
|
159
185
|
};
|
|
160
|
-
return this.findOne(filter, ...rest);
|
|
186
|
+
return this.findOne(filter, ...omitCallback(rest));
|
|
161
187
|
}
|
|
162
188
|
);
|
|
163
189
|
|
|
@@ -168,7 +194,7 @@ function applyQueries(schema) {
|
|
|
168
194
|
_id: id,
|
|
169
195
|
...getWithDeletedQuery(),
|
|
170
196
|
};
|
|
171
|
-
return this.findOne(filter, ...rest);
|
|
197
|
+
return this.findOne(filter, ...omitCallback(rest));
|
|
172
198
|
}
|
|
173
199
|
);
|
|
174
200
|
|
|
@@ -179,7 +205,7 @@ function applyQueries(schema) {
|
|
|
179
205
|
...filter,
|
|
180
206
|
...getWithDeletedQuery(),
|
|
181
207
|
};
|
|
182
|
-
return this.exists(filter, ...rest);
|
|
208
|
+
return this.exists(filter, ...omitCallback(rest));
|
|
183
209
|
}
|
|
184
210
|
);
|
|
185
211
|
|
|
@@ -190,7 +216,7 @@ function applyQueries(schema) {
|
|
|
190
216
|
...filter,
|
|
191
217
|
...getWithDeletedQuery(),
|
|
192
218
|
};
|
|
193
|
-
return this.countDocuments(filter, ...rest);
|
|
219
|
+
return this.countDocuments(filter, ...omitCallback(rest));
|
|
194
220
|
}
|
|
195
221
|
);
|
|
196
222
|
}
|
|
@@ -384,4 +410,171 @@ function getCollisions(obj1, obj2) {
|
|
|
384
410
|
return collisions;
|
|
385
411
|
}
|
|
386
412
|
|
|
387
|
-
//
|
|
413
|
+
// Hook Patch
|
|
414
|
+
|
|
415
|
+
function applyHookPatch(schema) {
|
|
416
|
+
const schemaPre = schema.pre;
|
|
417
|
+
const schemaPost = schema.post;
|
|
418
|
+
|
|
419
|
+
schema.pre = function (name, fn) {
|
|
420
|
+
if (name === 'restore') {
|
|
421
|
+
// Document hooks
|
|
422
|
+
schemaPre.call(this, 'save', getPreDocRestore(fn));
|
|
423
|
+
} else if (name === 'deleteOne') {
|
|
424
|
+
// Query Hooks
|
|
425
|
+
schemaPre.call(this, 'updateOne', getPreDelete(fn));
|
|
426
|
+
} else if (name === 'deleteMany') {
|
|
427
|
+
schemaPre.call(this, 'updateMany', getPreDelete(fn));
|
|
428
|
+
} else if (name === 'findOneAndDelete') {
|
|
429
|
+
schemaPre.call(this, 'findOneAndUpdate', getPreDelete(fn));
|
|
430
|
+
} else if (name === 'restoreOne') {
|
|
431
|
+
schemaPre.call(this, 'updateOne', getPreRestore(fn));
|
|
432
|
+
} else if (name === 'restoreMany') {
|
|
433
|
+
schemaPre.call(this, 'updateMany', getPreRestore(fn));
|
|
434
|
+
} else if (name === 'destroyOne') {
|
|
435
|
+
schemaPre.call(this, 'deleteOne', getPre(fn));
|
|
436
|
+
} else if (name === 'destroyMany') {
|
|
437
|
+
schemaPre.call(this, 'deleteMany', getPre(fn));
|
|
438
|
+
} else if (name === 'findDeleted') {
|
|
439
|
+
schemaPre.call(this, 'find', getPreDeleted(fn));
|
|
440
|
+
} else if (name === 'findOneDeleted') {
|
|
441
|
+
schemaPre.call(this, 'findOne', getPreDeleted(fn));
|
|
442
|
+
} else if (name === 'countDocumentsDeleted') {
|
|
443
|
+
schemaPre.call(this, 'countDocuments', getPreDeleted(fn));
|
|
444
|
+
} else if (name === 'findWithDeleted') {
|
|
445
|
+
schemaPre.call(this, 'find', getPreWithDeleted(fn));
|
|
446
|
+
} else if (name === 'findOneWithDeleted') {
|
|
447
|
+
schemaPre.call(this, 'findOne', getPreWithDeleted(fn));
|
|
448
|
+
} else if (name === 'countDocumentsWithDeleted') {
|
|
449
|
+
schemaPre.call(this, 'countDocuments', getPreWithDeleted(fn));
|
|
450
|
+
} else {
|
|
451
|
+
schemaPre.apply(this, arguments);
|
|
452
|
+
}
|
|
453
|
+
return this;
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
schema.post = function (name, fn) {
|
|
457
|
+
if (name === 'deleteOne') {
|
|
458
|
+
schemaPost.call(this, 'updateOne', getPostDelete(fn));
|
|
459
|
+
} else if (name === 'deleteMany') {
|
|
460
|
+
schemaPost.call(this, 'updateMany', getPostDelete(fn));
|
|
461
|
+
} else if (name === 'findOneAndDelete') {
|
|
462
|
+
schemaPost.call(this, 'findOneAndUpdate', getPostDelete(fn));
|
|
463
|
+
} else if (name === 'restoreOne') {
|
|
464
|
+
schemaPost.call(this, 'updateOne', getPostRestore(fn));
|
|
465
|
+
} else if (name === 'restoreMany') {
|
|
466
|
+
schemaPost.call(this, 'updateMany', getPostRestore(fn));
|
|
467
|
+
} else if (name === 'destroyOne') {
|
|
468
|
+
schemaPost.call(this, 'deleteOne', getPost(fn));
|
|
469
|
+
} else if (name === 'destroyMany') {
|
|
470
|
+
schemaPost.call(this, 'deleteMany', getPost(fn));
|
|
471
|
+
} else if (name === 'findDeleted') {
|
|
472
|
+
schemaPost.call(this, 'find', getPostDeleted(fn));
|
|
473
|
+
} else if (name === 'findOneDeleted') {
|
|
474
|
+
schemaPost.call(this, 'findOne', getPostDeleted(fn));
|
|
475
|
+
} else if (name === 'countDocumentsDeleted') {
|
|
476
|
+
schemaPost.call(this, 'countDocuments', getPostDeleted(fn));
|
|
477
|
+
} else if (name === 'findWithDeleted') {
|
|
478
|
+
schemaPost.call(this, 'find', getPostWithDeleted(fn));
|
|
479
|
+
} else if (name === 'findOneWithDeleted') {
|
|
480
|
+
schemaPost.call(this, 'findOne', getPostWithDeleted(fn));
|
|
481
|
+
} else if (name === 'countDocumentsWithDeleted') {
|
|
482
|
+
schemaPost.call(this, 'countDocuments', getPostWithDeleted(fn));
|
|
483
|
+
} else {
|
|
484
|
+
schemaPost.apply(this, arguments);
|
|
485
|
+
}
|
|
486
|
+
return this;
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// Needs to be separated as hooks check arity to
|
|
491
|
+
// determine the arguments to pass.
|
|
492
|
+
|
|
493
|
+
function getPre(fn, check) {
|
|
494
|
+
return function (next) {
|
|
495
|
+
runHook(this, fn, check, next, arguments);
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function getPost(fn, check) {
|
|
500
|
+
return function (res, next) {
|
|
501
|
+
runHook(this, fn, check, next, arguments);
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function runHook(query, fn, check, next, args) {
|
|
506
|
+
if (!check || check(query)) {
|
|
507
|
+
const ret = fn.apply(query, args);
|
|
508
|
+
if (ret instanceof Promise) {
|
|
509
|
+
ret.finally(next);
|
|
510
|
+
}
|
|
511
|
+
} else {
|
|
512
|
+
next();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function getPreDelete(fn) {
|
|
517
|
+
return getPre(fn, (query) => {
|
|
518
|
+
return query.get('deleted') === true;
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function getPreRestore(fn) {
|
|
523
|
+
return getPre(fn, (query) => {
|
|
524
|
+
return query.get('deleted') === false;
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function getPreDeleted(fn) {
|
|
529
|
+
return getPre(fn, (query) => {
|
|
530
|
+
return query.getFilter().deleted === true;
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function getPreWithDeleted(fn) {
|
|
535
|
+
return getPre(fn, (query) => {
|
|
536
|
+
return isEqual(query.getFilter().deleted, getWithDeletedQuery().deleted);
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function getPreDocRestore(fn) {
|
|
541
|
+
return getPre(fn, (doc) => {
|
|
542
|
+
return doc.isModified('deleted') && doc.deleted === false;
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function getPostDelete(fn) {
|
|
547
|
+
return getPost(fn, (query) => {
|
|
548
|
+
return query.get('deleted') === true;
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function getPostRestore(fn) {
|
|
553
|
+
return getPost(fn, (query) => {
|
|
554
|
+
return query.get('deleted') === false;
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function getPostDeleted(fn) {
|
|
559
|
+
return getPost(fn, (query) => {
|
|
560
|
+
return query.getFilter().deleted === true;
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
function getPostWithDeleted(fn) {
|
|
565
|
+
return getPost(fn, (query) => {
|
|
566
|
+
return isEqual(query.getFilter().deleted, getWithDeletedQuery().deleted);
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// Utils
|
|
571
|
+
|
|
572
|
+
// Mongoose >= v7 no longer accepts a callback for queries,
|
|
573
|
+
// however it still passes post hooks to static methods for
|
|
574
|
+
// some reason (this appears to be a bug), so omit functions
|
|
575
|
+
// here to allow projectsion/options to still be passed.
|
|
576
|
+
function omitCallback(args) {
|
|
577
|
+
return args.filter((arg) => {
|
|
578
|
+
return typeof arg !== 'function';
|
|
579
|
+
});
|
|
580
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-hooks.d.ts","sourceRoot":"","sources":["../src/delete-hooks.js"],"names":[],"mappings":"AAQA,qEAkDC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disallowed.d.ts","sourceRoot":"","sources":["../src/disallowed.js"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"disallowed.d.ts","sourceRoot":"","sources":["../src/disallowed.js"],"names":[],"mappings":"AAEA,mDA+BC"}
|
package/types/load.d.ts
CHANGED
|
@@ -4,7 +4,73 @@
|
|
|
4
4
|
* @param {string} name
|
|
5
5
|
* @returns mongoose.Model
|
|
6
6
|
*/
|
|
7
|
-
export function loadModel(definition: object, name: string): any
|
|
7
|
+
export function loadModel(definition: object, name: string): mongoose.Model<any, any, any, any, any, mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, any, any, any, {
|
|
8
|
+
[x: string]: any;
|
|
9
|
+
}, {
|
|
10
|
+
autoIndex?: boolean;
|
|
11
|
+
autoCreate?: boolean;
|
|
12
|
+
bufferCommands?: boolean;
|
|
13
|
+
bufferTimeoutMS?: number;
|
|
14
|
+
capped?: number | boolean | {
|
|
15
|
+
size?: number;
|
|
16
|
+
max?: number;
|
|
17
|
+
autoIndexId?: boolean;
|
|
18
|
+
};
|
|
19
|
+
collation?: mongoose.mongo.CollationOptions;
|
|
20
|
+
collectionOptions?: mongoose.mongo.CreateCollectionOptions;
|
|
21
|
+
timeseries?: mongoose.mongo.TimeSeriesCollectionOptions;
|
|
22
|
+
expireAfterSeconds?: number;
|
|
23
|
+
expires?: string | number;
|
|
24
|
+
collection?: string;
|
|
25
|
+
discriminatorKey?: string;
|
|
26
|
+
excludeIndexes?: boolean;
|
|
27
|
+
id?: boolean;
|
|
28
|
+
_id?: boolean;
|
|
29
|
+
minimize?: boolean;
|
|
30
|
+
optimisticConcurrency?: boolean;
|
|
31
|
+
pluginTags?: string[];
|
|
32
|
+
read?: string;
|
|
33
|
+
writeConcern?: mongoose.mongo.WriteConcern;
|
|
34
|
+
safe?: boolean | {
|
|
35
|
+
w?: string | number;
|
|
36
|
+
wtimeout?: number;
|
|
37
|
+
j?: boolean;
|
|
38
|
+
};
|
|
39
|
+
shardKey?: Record<string, unknown>;
|
|
40
|
+
strict?: boolean | "throw";
|
|
41
|
+
strictQuery?: boolean | "throw";
|
|
42
|
+
toJSON: {
|
|
43
|
+
getters: boolean;
|
|
44
|
+
versionKey: boolean;
|
|
45
|
+
transform: (doc: any, ret: any, options: any) => void;
|
|
46
|
+
} | mongoose.ToObjectOptions<any>;
|
|
47
|
+
toObject: {
|
|
48
|
+
getters: boolean;
|
|
49
|
+
versionKey: boolean;
|
|
50
|
+
transform: (doc: any, ret: any, options: any) => void;
|
|
51
|
+
} | mongoose.ToObjectOptions<any>;
|
|
52
|
+
typeKey?: string;
|
|
53
|
+
validateBeforeSave?: boolean;
|
|
54
|
+
validateModifiedOnly?: boolean;
|
|
55
|
+
versionKey?: string | boolean;
|
|
56
|
+
selectPopulatedPaths?: boolean;
|
|
57
|
+
skipVersioning?: {
|
|
58
|
+
[key: string]: boolean;
|
|
59
|
+
};
|
|
60
|
+
storeSubdocValidationError?: boolean;
|
|
61
|
+
timestamps: boolean | mongoose.SchemaTimestampsConfig;
|
|
62
|
+
suppressReservedKeysWarning?: boolean;
|
|
63
|
+
statics?: {
|
|
64
|
+
[x: string]: any;
|
|
65
|
+
};
|
|
66
|
+
methods?: any;
|
|
67
|
+
query?: any;
|
|
68
|
+
castNonArrays?: boolean;
|
|
69
|
+
virtuals?: mongoose.SchemaOptionsVirtualsPropertyType<any, any, any>;
|
|
70
|
+
overwriteModels?: boolean;
|
|
71
|
+
}, any, any>> & {
|
|
72
|
+
[x: string]: any;
|
|
73
|
+
};
|
|
8
74
|
/**
|
|
9
75
|
* Loads all model definitions in the given directory.
|
|
10
76
|
* Returns the full loaded model set.
|
package/types/load.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,sCAJW,MAAM,QACN,MAAM
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,sCAJW,MAAM,QACN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAahB;AAED;;;;GAIG;AACH,sCAFW,MAAM,mBAkBhB"}
|
package/types/query.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.js"],"names":[],"mappings":"AAIA,oDAUC"}
|
package/types/schema.d.ts
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* @param {mongoose.SchemaOptions} options
|
|
7
7
|
* @returns mongoose.Schema
|
|
8
8
|
*/
|
|
9
|
-
export function createSchema(definition: object, options?: mongoose.SchemaOptions): mongoose.Schema<any, mongoose.Model<any, any, any, any, any
|
|
9
|
+
export function createSchema(definition: object, options?: mongoose.SchemaOptions): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, any, any, any, {
|
|
10
|
+
[x: string]: any;
|
|
11
|
+
}, {
|
|
10
12
|
autoIndex?: boolean;
|
|
11
13
|
autoCreate?: boolean;
|
|
12
14
|
bufferCommands?: boolean;
|
|
@@ -16,8 +18,9 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
|
|
|
16
18
|
max?: number;
|
|
17
19
|
autoIndexId?: boolean;
|
|
18
20
|
};
|
|
19
|
-
collation?:
|
|
20
|
-
|
|
21
|
+
collation?: mongoose.mongo.CollationOptions;
|
|
22
|
+
collectionOptions?: mongoose.mongo.CreateCollectionOptions;
|
|
23
|
+
timeseries?: mongoose.mongo.TimeSeriesCollectionOptions;
|
|
21
24
|
expireAfterSeconds?: number;
|
|
22
25
|
expires?: string | number;
|
|
23
26
|
collection?: string;
|
|
@@ -29,7 +32,7 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
|
|
|
29
32
|
optimisticConcurrency?: boolean;
|
|
30
33
|
pluginTags?: string[];
|
|
31
34
|
read?: string;
|
|
32
|
-
writeConcern?:
|
|
35
|
+
writeConcern?: mongoose.mongo.WriteConcern;
|
|
33
36
|
safe?: boolean | {
|
|
34
37
|
w?: string | number;
|
|
35
38
|
wtimeout?: number;
|
|
@@ -42,14 +45,15 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
|
|
|
42
45
|
getters: boolean;
|
|
43
46
|
versionKey: boolean;
|
|
44
47
|
transform: (doc: any, ret: any, options: any) => void;
|
|
45
|
-
} | mongoose.ToObjectOptions
|
|
48
|
+
} | mongoose.ToObjectOptions<any>;
|
|
46
49
|
toObject: {
|
|
47
50
|
getters: boolean;
|
|
48
51
|
versionKey: boolean;
|
|
49
52
|
transform: (doc: any, ret: any, options: any) => void;
|
|
50
|
-
} | mongoose.ToObjectOptions
|
|
53
|
+
} | mongoose.ToObjectOptions<any>;
|
|
51
54
|
typeKey?: string;
|
|
52
55
|
validateBeforeSave?: boolean;
|
|
56
|
+
validateModifiedOnly?: boolean;
|
|
53
57
|
versionKey?: string | boolean;
|
|
54
58
|
selectPopulatedPaths?: boolean;
|
|
55
59
|
skipVersioning?: {
|
|
@@ -57,14 +61,16 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
|
|
|
57
61
|
};
|
|
58
62
|
storeSubdocValidationError?: boolean;
|
|
59
63
|
timestamps: boolean | mongoose.SchemaTimestampsConfig;
|
|
60
|
-
|
|
61
|
-
statics?:
|
|
64
|
+
suppressReservedKeysWarning?: boolean;
|
|
65
|
+
statics?: {
|
|
66
|
+
[x: string]: any;
|
|
67
|
+
};
|
|
62
68
|
methods?: any;
|
|
63
69
|
query?: any;
|
|
64
70
|
castNonArrays?: boolean;
|
|
65
71
|
virtuals?: mongoose.SchemaOptionsVirtualsPropertyType<any, any, any>;
|
|
66
72
|
overwriteModels?: boolean;
|
|
67
|
-
}, any>;
|
|
73
|
+
}, any, any>;
|
|
68
74
|
export function normalizeAttributes(arg: any, path?: any[]): any;
|
|
69
75
|
import mongoose from "mongoose";
|
|
70
76
|
//# sourceMappingURL=schema.d.ts.map
|
package/types/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.js"],"names":[],"mappings":"AAoBA;;;;;;;GAOG;AACH,yCAJW,MAAM,YACN,SAAS,aAAa
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.js"],"names":[],"mappings":"AAoBA;;;;;;;GAOG;AACH,yCAJW,MAAM,YACN,SAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAuChC;AAED,iEAsBC"}
|
package/types/search.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"AAeA,gEAmDC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.js"],"names":[],"mappings":";;;IAWa,2DAIV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soft-delete.d.ts","sourceRoot":"","sources":["../src/soft-delete.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"soft-delete.d.ts","sourceRoot":"","sources":["../src/soft-delete.js"],"names":[],"mappings":"AAIA,mDAIC;AAiRD,oEAsBC;AAgDD,2DAKC"}
|
package/types/testing.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* [Link](https://github.com/bedrockio/model#testing)
|
|
6
6
|
* @returns mongoose.Model
|
|
7
7
|
*/
|
|
8
|
-
export function createTestModel(...args: any[]): mongoose.Model<any, unknown, unknown, unknown, any>;
|
|
8
|
+
export function createTestModel(...args: any[]): mongoose.Model<any, unknown, unknown, unknown, any, any>;
|
|
9
9
|
export function getTestModelName(): string;
|
|
10
10
|
import mongoose from "mongoose";
|
|
11
11
|
//# sourceMappingURL=testing.d.ts.map
|
package/types/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.js"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,0GAiBC;AAED,2CAEC"}
|