You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you want to request a feature or report a bug?
bug What is the current behavior?
declaring a variable with type UpdateQuery if you assign a value to this variable it returns the error "Cannot assign to ' ' because it is a read-only property" If the current behavior is a bug, please provide the steps to reproduce.
import mongoose, { Schema, model, UpdateQuery } from 'mongoose';
async function run() {
mongoose.connect('mongodb://localhost:27017/test');
interface User {
phone?: string;
name?: string
}
const UserModel = model<User>('User', new Schema<User>({
phone: String,
name: String
}));
const updateQuery : UpdateQuery<User> = {name :'John'};
if (1==1) {
updateQuery.phone = 'XXXX'
}
const user = await UserModel.updateOne({},updateQuery)
}
What is the expected behavior?
it should not return an error
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js: 14.17.4 , Mongoose: 6.0.7 , MongoDB: 4.4.3
The text was updated successfully, but these errors were encountered:
@jdegger please open a new issue and follow the issue template, you're missing a lot of key information, including mongoose version, typescript version, typescript config, etc.
Below script compiles without error on Mongoose 7.2.2, TypeScript 4.9.4.
Do you want to request a feature or report a bug?
bug
What is the current behavior?
declaring a variable with type UpdateQuery if you assign a value to this variable it returns the error "Cannot assign to ' ' because it is a read-only property"
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
it should not return an error
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js: 14.17.4 , Mongoose: 6.0.7 , MongoDB: 4.4.3
The text was updated successfully, but these errors were encountered: