Skip to content

Commit 86bca4f

Browse files
joshuatavaly
authored andcommitted
refactor: Remove default schema __v version property
BREAKING CHANGE: Schemas no longer have a default `__v` property defined. Users who have migrated from Mongoose or are otherwise taking advantage of this property will have to manually add it to their schema definitions.
1 parent eda078a commit 86bca4f

File tree

3 files changed

+0
-47
lines changed

3 files changed

+0
-47
lines changed

src/__tests__/index.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ describe('index', () => {
130130
$jsonSchema: {
131131
additionalProperties: false,
132132
properties: {
133-
__v: {
134-
type: 'number',
135-
},
136133
_id: {
137134
bsonType: 'objectId',
138135
},
@@ -166,9 +163,6 @@ describe('index', () => {
166163
$jsonSchema: {
167164
additionalProperties: false,
168165
properties: {
169-
__v: {
170-
type: 'number',
171-
},
172166
_id: {
173167
bsonType: 'objectId',
174168
},
@@ -205,9 +199,6 @@ describe('index', () => {
205199
$jsonSchema: {
206200
additionalProperties: false,
207201
properties: {
208-
__v: {
209-
type: 'number',
210-
},
211202
_id: {
212203
bsonType: 'objectId',
213204
},
@@ -227,9 +218,6 @@ describe('index', () => {
227218
$jsonSchema: {
228219
additionalProperties: false,
229220
properties: {
230-
__v: {
231-
type: 'number',
232-
},
233221
_id: {
234222
bsonType: 'objectId',
235223
},

src/__tests__/schema.test.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ describe('schema', () => {
2222
$validationLevel: 'strict',
2323
additionalProperties: false,
2424
properties: {
25-
__v: {
26-
type: 'number',
27-
},
2825
_id: {
2926
bsonType: 'objectId',
3027
},
@@ -80,9 +77,6 @@ describe('schema', () => {
8077
$validationLevel: 'strict',
8178
additionalProperties: false,
8279
properties: {
83-
__v: {
84-
type: 'number',
85-
},
8680
_id: {
8781
bsonType: 'objectId',
8882
},
@@ -139,9 +133,6 @@ describe('schema', () => {
139133
$validationLevel: 'strict',
140134
additionalProperties: false,
141135
properties: {
142-
__v: {
143-
type: 'number',
144-
},
145136
_id: {
146137
bsonType: 'objectId',
147138
},
@@ -197,9 +188,6 @@ describe('schema', () => {
197188
$validationLevel: 'strict',
198189
additionalProperties: false,
199190
properties: {
200-
__v: {
201-
type: 'number',
202-
},
203191
_id: {
204192
bsonType: 'objectId',
205193
},
@@ -252,9 +240,6 @@ describe('schema', () => {
252240
$validationLevel: 'strict',
253241
additionalProperties: false,
254242
properties: {
255-
__v: {
256-
type: 'number',
257-
},
258243
_createdDate: {
259244
bsonType: 'date',
260245
},
@@ -324,9 +309,6 @@ describe('schema', () => {
324309
$validationLevel: 'strict',
325310
additionalProperties: false,
326311
properties: {
327-
__v: {
328-
type: 'number',
329-
},
330312
_createdDate: {
331313
bsonType: 'date',
332314
},
@@ -385,9 +367,6 @@ describe('schema', () => {
385367
$validationLevel: 'strict',
386368
additionalProperties: false,
387369
properties: {
388-
__v: {
389-
type: 'number',
390-
},
391370
_id: {
392371
type: 'string',
393372
},
@@ -431,9 +410,6 @@ describe('schema', () => {
431410
$validationLevel: 'strict',
432411
additionalProperties: false,
433412
properties: {
434-
__v: {
435-
type: 'number',
436-
},
437413
_id: {
438414
type: 'number',
439415
},
@@ -523,9 +499,6 @@ describe('schema', () => {
523499
$validationLevel: 'moderate',
524500
additionalProperties: false,
525501
properties: {
526-
__v: {
527-
type: 'number',
528-
},
529502
_id: {
530503
bsonType: 'objectId',
531504
},
@@ -769,9 +742,6 @@ describe('schema', () => {
769742
$validationLevel: 'strict',
770743
additionalProperties: false,
771744
properties: {
772-
__v: {
773-
type: 'number',
774-
},
775745
_id: {
776746
bsonType: 'objectId',
777747
},
@@ -867,9 +837,6 @@ describe('schema', () => {
867837
$validationLevel: 'moderate',
868838
additionalProperties: false,
869839
properties: {
870-
__v: {
871-
type: 'number',
872-
},
873840
_id: {
874841
bsonType: 'objectId',
875842
},

src/schema.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ export default function schema<
130130
[createdAtProperty]: types.date({ required: true }),
131131
[updatedAtProperty]: types.date({ required: true }),
132132
}),
133-
// Support for legacy data generated by Mongoose
134-
__v: types.number(),
135133
},
136134
{ required: true }
137135
);

0 commit comments

Comments
 (0)