-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Deps] Update to Mongoose 6 #170
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The goal is to get to v8, the current version. But [1] advises to go major version by major version instead of making an abrupt jump. mongoose@6 needs mongodb@4, but this requirement is already satisfied. [1]: https://mongoosejs.com/docs/migrating_to_6.html
Resolves this build error: ```log src/models/CardsMongoDB.ts:86:23 - error TS2769: No overload matches this call. Overload 1 of 3, '(filter?: FilterQuery<ICardRaw> | undefined, projection?: ProjectionType<ICardRaw> | null | undefined, options?: QueryOptions<ICardRaw> | null | undefined, callback?: Callback<...> | undefined): Query<...>', gave the following error. Argument of type 'Partial<ICard>' is not assignable to parameter of type 'FilterQuery<ICardRaw>'. Type 'Partial<ICard>' is not assignable to type 'RootQuerySelector<ICardRaw>'. Types of property '$where' are incompatible. Type 'Record<string, unknown> | undefined' is not assignable to type 'string | Function | undefined'. Type 'Record<string, unknown>' is not assignable to type 'string | Function | undefined'. Type 'Record<string, unknown>' is missing the following properties from type 'Function': apply, call, bind, prototype, and 5 more. Overload 2 of 3, '(filter?: FilterQuery<ICardRaw> | undefined, projection?: ProjectionType<ICardRaw> | null | undefined, callback?: Callback<(Document<unknown, any, ICardRaw> & Omit<...>) | null> | undefined): Query<...>', gave the following error. Argument of type 'Partial<ICard>' is not assignable to parameter of type 'FilterQuery<ICardRaw>'. Overload 3 of 3, '(filter?: FilterQuery<ICardRaw> | undefined, callback?: Callback<(Document<unknown, any, ICardRaw> & Omit<ICardRaw & Required<{ _id: string; }>, never>) | null> | undefined): Query<...>', gave the following error. Argument of type 'Partial<ICard>' is not assignable to parameter of type 'FilterQuery<ICardRaw>'. 86 return Card.findOne(query).select(projection).exec(); ~~~~~ ```
Fixes this build error: ```log src/models/CardsMongoDB.ts:260:11 - error TS2345: Argument of type 'object' is not assignable to parameter of type 'string | { [key: string]: SortOrder | { $meta: "textScore"; }; } | [string, SortOrder][] | null | undefined'. 260 .sort(queryObject.sortCriteria) ~~~~~~~~~~~~~~~~~~~~~~~~ ```
…unique"]` Fixes these errors: ```log src/models/mongoose_models/Token.ts:19:5 - error TS2322: Type '{ type: StringConstructor; required: true; unique: (string | true)[]; }' is not assignable to type 'SchemaDefinitionProperty<string> | undefined'. Types of property 'unique' are incompatible. Type '(string | true)[]' is not assignable to type 'number | boolean | undefined'. 19 token_id: { ~~~~~~~~ src/models/mongoose_models/UserSchema.ts:28:5 - error TS2322: Type '{ type: StringConstructor; required: true; unique: (string | true)[]; immutable: true; match: RegExp; }' is not assignable to type 'SchemaDefinitionProperty<string> | undefined'. Types of property 'unique' are incompatible. Type '(string | true)[]' is not assignable to type 'number | boolean | undefined'. 28 username: { ~~~~~~~~ ``` AFAICT, the custom string doesn't seem like it was ever supported in v5 [1]. [1]: https://mongoosejs.com/docs/5.x/docs/validation.html#the-unique-option-is-not-a-validator
```log src/models/MetadataMongoDB.ts:117:46 - error TS2769: No overload matches this call. Overload 1 of 3, '(filter?: FilterQuery<IMetadataRaw> | undefined, projection?: ProjectionType<IMetadataRaw> | null | undefined, options?: QueryOptions<...> | ... 1 more ... | undefined, callback?: Callback<...> | undefined): Query<...>', gave the following error. Argument of type 'Partial<IMetadata>' is not assignable to parameter of type 'FilterQuery<IMetadataRaw>'. Type 'Partial<IMetadata>' is not assignable to type 'RootQuerySelector<IMetadataRaw>'. Types of property '$where' are incompatible. Type 'Record<string, unknown> | undefined' is not assignable to type 'string | Function | undefined'. Overload 2 of 3, '(filter?: FilterQuery<IMetadataRaw> | undefined, projection?: ProjectionType<IMetadataRaw> | null | undefined, callback?: Callback<...> | undefined): Query<...>', gave the following error. Argument of type 'Partial<IMetadata>' is not assignable to parameter of type 'FilterQuery<IMetadataRaw>'. Overload 3 of 3, '(filter?: FilterQuery<IMetadataRaw> | undefined, callback?: Callback<(Document<unknown, any, IMetadataRaw> & Omit<IMetadataRaw & { ...; }, never>) | null> | undefined): Query<...>', gave the following error. Argument of type 'Partial<IMetadata>' is not assignable to parameter of type 'FilterQuery<IMetadataRaw>'. 117 const metadataDoc = await Metadata.findOne(metadataQuery).exec(); ~~~~~~~~~~~~~ ```
This package already existed but as a dependency of Mongoose. This commit brings it to the top-level dependencies so that we can take advantage of MongoDB's TS types. [1] We had not used @types/mongodb, so removing that package isn't applicable to us. [1]: https://github.com/mongodb/node-mongodb-native/blob/4.0/docs/CHANGES_4.0.0.md#typescript
```log src/models/MetadataMongoDB.ts:204:3 - error TS2322: Type 'Promise<DeleteResult>' is not assignable to type 'Promise<void>'. Type 'DeleteResult' is not assignable to type 'void'. 204 return Metadata.deleteMany({ createdById: payload.userIDInApp }).exec(); ~~~~~~ ``` [1]: https://mongoosejs.com/docs/6.x/docs/migrating_to_6.html#mongodb-driver-40
```log src/models/mongoose_models/MetadataCardSchema.ts:47:5 - error TS2322: Type '{ type: MapConstructor; default: { cardIDs: never[]; length: number; dailyTarget: number; timeStamp: () => number; }; }' is not assignable to type 'SchemaDefinitionProperty<IStreak> | undefined'. Type '{ type: MapConstructor; default: { cardIDs: never[]; length: number; dailyTarget: number; timeStamp: () => number; }; }' is not assignable to type 'undefined'. 47 streak: { ~~~~~~ ```
```log src/models/DailyTasks.ts:57:29 - error TS2345: Argument of type '{ updateOne: { filter?: FilterQuery<IMetadata> | undefined; update?: UpdateQuery<IMetadata> | undefined; }; }[]' is not assignable to parameter of type 'AnyBulkWriteOperation<IMetadataRaw>[]'. Type '{ updateOne: { filter?: FilterQuery<IMetadata> | undefined; update?: UpdateQuery<IMetadata> | undefined; }; }' is not assignable to type 'AnyBulkWriteOperation<IMetadataRaw>'. Type '{ updateOne: { filter?: FilterQuery<IMetadata> | undefined; update?: UpdateQuery<IMetadata> | undefined; }; }' is not assignable to type '{ updateOne: UpdateOneModel<IMetadataRaw>; }'. The types of 'updateOne.filter' are incompatible between these types. Type 'FilterQuery<IMetadata> | undefined' is not assignable to type 'Filter<IMetadataRaw>'. Type 'undefined' is not assignable to type 'Filter<IMetadataRaw>'. 57 return Metadata.bulkWrite(bulkWriteOps); ~~~~~~~~~~~~ ```
`useNewUrlParser` is `true` by default and should not be specified in client code. [1] `poolSize` has been replaced with `maxPoolSize` which defaults to `100`. [2] [1]: https://mongoosejs.com/docs/migrating_to_6.html#no-more-deprecation-warning-options [2]: https://mongoosejs.com/docs/migrating_to_6.html#mongodb-driver-40
Your Render PR Server URL is https://flashcards-pr-170.onrender.com. Follow its progress at https://dashboard.render.com/web/srv-cpmsrhhu0jms739c8jm0. |
Contributes to #174 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.