Node.js 忽略只读上的Mongoose架构
我有一个集合,其中数据符合几个不同模式中的一个。这些都在一个集合中的原因是我需要能够一起查询它们,利用MongoDB的无模式特性 有没有一种方法可以在忽略模式的情况下使用mongoose查询集合?例如:Node.js 忽略只读上的Mongoose架构,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,我有一个集合,其中数据符合几个不同模式中的一个。这些都在一个集合中的原因是我需要能够一起查询它们,利用MongoDB的无模式特性 有没有一种方法可以在忽略模式的情况下使用mongoose查询集合?例如: var adam = new ContractCustomer({ // Contract customer data saved to customers collection }) var betty = new PaygCustomer({ // PAYG customer da
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.
我建议您使用连接到数据库,并从那里进行
find
。据我所知,使用mongoose无法执行无模式查询
mongoose的全部要点是使用模式
(保持与猫鼬的连接,只需打开并行连接)