【发布时间】:2020-08-29 04:21:54
【问题描述】:
我有这个猫鼬模式
const AddressSchema = new Schema({
city : String,
address : String,
favorite : Boolean,
description:String,
lat : String,
lng : String,
});
export const orderSchema = new Schema({
id: {
type: Number,
require: [true, "EL id es necesario"],
default: 0
},
newAddress : AddressSchema,
});
我正在尝试使用 newAddress 对象中的 city 参数搜索记录,类似这样的
//ordersModel its the same Order Schema
const ActiveOrders = await this.ordersModel.find({newAddress:{city : city}});
但我得到了这个错误
(property) newAddress?: Condition<Address>
No overload matches this call.
The last overload gave the following error.
Type '{ city: string; }' is not assignable to type 'Condition<Address>'.
Type '{ city: string; }' is missing the following properties from type 'Address': address, favorite, description, lat, lng
【问题讨论】:
标签: node.js mongodb mongoose nestjs