Firepit is a fully featured ORM, loosley based on Sails JS. Click through to see example of how to define models and allow Firepit to structure your database project.
Use our easy to follow guides on how to add Firepit to your project
Firepit is a feature rich ORM, click here for description and examples in our library.
If you are new to Firestore, please use of startup guide on how to create a project before using Firepit...
It's easy to get started with Firepit
firebase.firepit().createModel('role', {
attributes: {
name: {
type: 'string',
required: true,
},
},
});
firebase.firepit().createModel('user', {
attributes: {
name: {
type: 'string',
required: true,
},
roles: {
hasMany: roles,
via: 'name',
},
},
});
const Role = firepit().model('role');
const newRole = await Role.create({ name: administrator });
const User = firepit().model('user');
await User.create({ 'Joe Bloggs', roles: [...newRole.id] });
const users = await User.find({}).populate('roles');
console.log(users);
//Output
{
"id": "47gIS6WwWD3tqLJDyycN",
"name": "Joe Bloggs",
"roles": [
{
"id": "aq7PUv2dtH0au0hDjdjG",
"name": "administrator",
"createdAt": {
"_seconds": 1538387482,
"_nanoseconds": 531000000
},
"createdBy": "_SERVER_",
"updatedAt": {
"_seconds": 1538387482,
"_nanoseconds": 531000000
},
"updatedBy": "_SERVER_"
}
],
"createdAt": {
"_seconds": 1538387482,
"_nanoseconds": 898000000
},
"createdBy": "_SERVER_",
"updatedAt": {
"_seconds": 1538387482,
"_nanoseconds": 898000000
},
"updatedBy": "_SERVER_"
}