0.0.0 • Published 6 years ago

firepit v0.0.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
6 years ago

Firepit

npm version NPM downloads Chat Donate

Firepit is a JavaScript ORM for Firebase Cloud Firestore. It provides a common interface for interacting with the service inspired by Mongoose and Waterline. Firepit allows you to be as explict or implicit as you want by defining your datastore in models.

NOTE: This is for the NodeJS Firebase Admin SDK only right now - it has a lot of features the Web SDK currently does not have yet that aid in querying / multi-document access / operations.

| Documentation | npm |

npm install --save firepit@next

Quick Start

const firebase = require('firebase-admin');
const firepit = require('firepit');
const app = firebase.initializeApp(...);

firepit.use(app);

const User = firebase.firepit().createModel('User', {
  attributes: {
    name: 'string',
    age: {
      type: 'integer',
      validate(age) {
        if (age < 18) throw new Error('Users must be at least 18 years old.');
      },
    },
  },
});

User
  .create({
    name: 'Ben Dover',
    age: 20,
  })
  .then((created) => {
      console.log('User created!', created);
  });