使用mongoose但连接到Firebase

时间:2016-07-06 15:06:05

标签: mongoose firebase firebase-realtime-database

我正在考虑使用mongoose进行数据建模,但我需要使用持久层来使用Firebase。是否有可能实现这一目标?例如,覆盖数据CRUD的一些moongose方法?

1 个答案:

答案 0 :(得分:-1)

可以使用插件来实现这一目标。执行以下步骤:

npm install mongoose-fire

对每种型号使用以下陈述:

const mongoose-fire = require('mongoose-fire'); 
exampleSchema.plugin(mongoose-fire);

访问事件:

 Model.on('create')
 Modle.on('update')
 Model.on('update:<attr>')
 Modle.on('remove')

参考链接:https://www.npmjs.com/package/mongoose-fire