【发布时间】:2018-12-01 16:14:20
【问题描述】:
我有一个数据符合几种不同模式之一的集合。这些都在一个集合中的原因是我需要能够一起查询它们,利用 MongoDB 的无模式特性。
有没有办法在忽略模式的情况下使用 mongoose 查询集合?举个例子:
var adam = new ContractCustomer({
// Contract customer data saved to customers collection
})
var betty = new PaygCustomer({
// PAYG customer data saved to customers collection
})
adam.save()
betty.save()
Customers.find({}).exec().then() // Query all the customers regardless of which schema they belong to.
【问题讨论】: