mongoose SchemaFactory 设置createdAt、updatedAt为时间戳 BG7ZAG | 2023-9-21 14:37 | 614 | 0 | 程序开发 34 字 | 1 分钟内 @Schema({ timestamps: { currentTime: () => Date.now(), // 根据官方文档写法 }, }) export class Schema extends Document { ... @Prop() createdAt: number; // 需要修改类型为number才生效 @Prop() u… createdAtMongoMongoDBMongooseupdatedAt时间戳
MongoDB配置账户密码连接报Authentication failed. BG7ZAG | 2022-8-09 18:25 | 918 | 0 | 程序开发 179 字 | 1 分钟内 当我们MongoDB启用auth认证的时候,程序连接数据库时报 MongoServerError: Authentication failed. 但是呢,url、数据库名称、账号、密码都正确,为什么会报这个认证错误呢? 首先去服务器查看MongoDB的日志,日志显示: UserNotFound: Could not find user xxx@ad… Authentication failedauthSourceauth认证MongoMongoDB安全认证