我尝试使用accountStatus.activated = false来获取所有用户。但是我就是做不到。
User.find({accountStatus: {activated: false}}) ...
controller.ts
import {User} from "../models/userModel";
public static getAllUsers(request, response, next): void {
User.find().then(data => response.json(data)).catch(next);
}
userModel
const user:Schema = new Schema({
name_first: {
type: String,
required: [true, 'First Name is required (name_first)']
},
accountStatus: {
activated: {
type: Boolean,
default: false,
required: true
},
}
});
export const User: Model = model("User", user);
请帮助我D:
答案 0 :(得分:1)
使用点符号:
User.find({'accountStatus.activated': false})