firebless
v0.2.1
Published
Firebless allows you to create repositories from Firestore collections
Downloads
10
Maintainers
Readme
Firebless
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.