-
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
Commits on Jun 11, 2024
-
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
Configuration menu - View commit details
-
Copy full SHA for 8a39bfc - Browse repository at this point
Copy the full SHA 8a39bfcView commit details -
[Mongoose] Fix Card.findOne typing
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(); ~~~~~ ```
Configuration menu - View commit details
-
Copy full SHA for 0a8624d - Browse repository at this point
Copy the full SHA 0a8624dView commit details -
[Mongoose] Stronger typing for Card.sort object
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) ~~~~~~~~~~~~~~~~~~~~~~~~ ```
Configuration menu - View commit details
-
Copy full SHA for f5ba28c - Browse repository at this point
Copy the full SHA f5ba28cView commit details -
[Mongoose] Pass
unique: true
instead of `unique: [true, "x must be ……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
Configuration menu - View commit details
-
Copy full SHA for 09a4cbd - Browse repository at this point
Copy the full SHA 09a4cbdView commit details -
[Mongoose] Fix Metadata.findOne typing
```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(); ~~~~~~~~~~~~~ ```
Configuration menu - View commit details
-
Copy full SHA for 5dbb4c7 - Browse repository at this point
Copy the full SHA 5dbb4c7View commit details -
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
Configuration menu - View commit details
-
Copy full SHA for 46a3e14 - Browse repository at this point
Copy the full SHA 46a3e14View commit details -
[Mongo] Fix return typing for Metadata.deleteMany
```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
Configuration menu - View commit details
-
Copy full SHA for 3dc965a - Browse repository at this point
Copy the full SHA 3dc965aView commit details -
[Mongoose] Fix typings for IStreak
```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: { ~~~~~~ ```
Configuration menu - View commit details
-
Copy full SHA for bd571b4 - Browse repository at this point
Copy the full SHA bd571b4View commit details
Commits on Jun 15, 2024
-
[Mongo] Fix typings for setting IStreakRaw
```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); ~~~~~~~~~~~~ ```
Configuration menu - View commit details
-
Copy full SHA for b581365 - Browse repository at this point
Copy the full SHA b581365View commit details -
[Mongoose] Fix calls to connect
`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
Configuration menu - View commit details
-
Copy full SHA for 8c140dd - Browse repository at this point
Copy the full SHA 8c140ddView commit details