2017-10-12 6 views
1

nodejにfirestoreをサポートするORMはありますか?私は特にPythonでndbを好きにしていました。firestoreのORM

+1

私はこれまでのことは認識していません(まだ作成していません)。 –

答えて

5

私たちは1つを取り組んでいます(私たちはInvertase/creators of react-native-firebaseを意味します)。それ以前にマングースやウォーターラインを使用していたのであれば、私たちがインスピレーションのために使用しているように過度に慣れているでしょう。

これは、すべてのまだ内部ですが、あなたの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 
 
    // e.g /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; 
 
});

当社に目を光らせる不協和音、Github orgまたはtwitter - 数日でパブリックアルファを持つことを望みます。

上記の例では、ページ分類(スキップ、リミット、ページ)、createOrUpdate、findOrCreate、subscribe()のようなものをサポートする予定ですが、 firestoreに送信された1、残り行わクライアント側)など

更新:

非常に早い段階レポのAはgithubのhereに公表されました。それは一般的に動作し、ドキュメントはまだ必要としているいくつかのことがコード賢明な欠落 - 使用法のテストを参照してください - それはあなたが貢献したい場合は:)私たちはFirepitのために中断している現時点でReact Native Firebaseのリリースを進めている現在、

+1

これはどうやって来るのですか? – sirvon

+0

@sirvonの説明は最新情報と更新されました。+ repo link – Salakar