firebless

0.2.1 • Public • Published

Firebless

Build Status Npm Coverage Maintainability Vulnerabilities License

Firebless allows you to create repositories from Firestore collections. It providing basic methods such as detail, list, create, update, delete and more.

Install

npm i firebless

Basic usage

import { defaultFirestoreRepository, initFirestore } from 'firebless';

const db = initFirestore({/* todo */}); // or use custom instance

interface User {
  id?: string;
  name: string;
}
const userRepository = defaultFirestoreRepository.bind<User>(db.collection('users'));
// userRepository.detailById('123')
// userRepository.list({ name: 'Test' })
// ...

Custom repository

import { defaultFirestoreRepository, initFirestore } from 'firebless';

const db = initFirestore({/* todo */}); // or use custom instance

interface User {
  id?: string;
  name: string;
}
const userRepository = (defaultRepo => {
    const list = () => {
        // custom logic
        return defaultRepo.list({}, defaultRepo.getCollection().orderBy('name', 'asc'));
    };
    return {
        ...defaultRepo,
        list,
    };
})(defaultFirestoreRepository.bind<User>(db.collection('users')));

Examples

Debug

You need to set the NODE_DEBUG variable to the firebless.

Testing

npm t

npm run test:coverage

License

This project is licensed under MIT.

Readme

Keywords

Package Sidebar

Install

npm i firebless

Weekly Downloads

4

Version

0.2.1

License

MIT

Unpacked Size

89.8 kB

Total Files

27

Last publish

Collaborators

  • stefan-prokop-cz