When attempting to run a mongoose schema with a timestamp, I encountered an error:
error TS2554: Expected 0-1 arguments, but got 2.
{ timestamps: true }
Below is the schema code:
const Schema = mongoose.Schema;
const loginUserSchema = new Schema(
{
userId: { type: String, required: false }
},
{ timestamps: true }
);
loginUserSchema.index({ userName: 'text' });
export const LoginUserModel = mongoose.model("loginUser", loginUserSchema) ;
Here is my package.json:
"dependencies": {
"@types/express": "^4.17.9",
"@types/mongoose": "^5.7.7",
"@types/node": "^13.9.2",
"@types/react-router-dom": "^5.1.3",
"body-parser": "^1.13.3",
"config": "^3.3.2",
"cors": "^2.8.1",
"express": "^4.13.3",
"express-session": "^1.14.2",
"jsonwebtoken": "^8.5.1",
"keycloak-connect": "github:keycloak/keycloak-nodejs-connect",
"moment": "^2.29.1",
"mongodb": "^3.5.5",
"mongoose": "^5.10.9",
"nodemon": "^2.0.5",
"react-router-dom": "^5.1.2",
"socket.io": "^2.3.0",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
}
Are there any changes I should make to get this working?