Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 忽略只读上的Mongoose架构_Node.js_Mongodb_Mongoose - Fatal编程技术网

Node.js 忽略只读上的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

我有一个集合,其中数据符合几个不同模式中的一个。这些都在一个集合中的原因是我需要能够一起查询它们,利用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.

我建议您使用连接到数据库,并从那里进行
find
。据我所知,使用mongoose无法执行无模式查询

mongoose的全部要点是使用模式

(保持与猫鼬的连接,只需打开并行连接)