ORM for firestore

是否有任何支持nodejs中的firestore的ORM? 我特别喜欢Python中的ndb。

我们正在研究一个(我们指的是Invertase / react-native-firebase的创build者 )。 如果您之前已经在节点上使用mongoose或水线,那么您会发现它过于熟悉,因为这正是我们用来获取灵感的地方。

这一切仍然是内部的,但给你一个API的概念这里是我们在内部的模型/用法的例子之一:

const User = model('User', { // auto create/update date fields autoCreatedAt: true, autoUpdatedAt: true, // auto created/updated by fields, uses current auth user or 'service-account' autoUpdatedBy: true, autoCreatedBy: true, // toggle schema/less. If turned off, this will allow you to store arbitrary // data in a record. If turned on, only attributes defined in the model's // attributes object will be stored. schema: true, attributes: { first_name: { type: 'string', required: true }, last_name: { type: 'string', required: true }, // virtual field support full_name() { return `${this.first_name} ${this.last_name}`; }, age: { type: 'integer' }, email: { type: 'email', required: true }, someBool: { type: 'boolean', defaultsTo: false }, // association example- in this case a child collection of the users doc // eg /users/id/posts posts: { collection: 'posts', } } }); // magic methods based on attributes // findByX or findOneByX User.findByAge(27).then((val) => { // val = [] or [document object] }).catch((error) => { debugger; }); // magic methods based on attributes // findByX or findOneByX User.findByName('mike').then((val) => { // val = [] or [document object] }).catch((error) => { debugger; }); // find a single document User.findOne().then((val) => { // val = undefined or document object }).catch((error) => { debugger; }); // find multiple docs User.find({ name: 'mike', age: 27, someBool: true, }).then((val) => { // val = [] or [document object] }).catch((error) => { debugger; }); // find multiple docs with age between range User.find({ someBool: true, age: { $gte: 27, $lte: 35 } }).then((val) => { // val = [] or [document object] }).catch((error) => { debugger; });