FireORM24 is a lightweight wrapper for firebase-admin designed to simplify interactions with Firestore databases. By abstracting the access layer and offering a familiar repository pattern, FireORM24 streamlines the development process for applications that use Firestore, allowing developers to concentrate on creating new features without dealing with the intricacies of Firestore.
Willy Ovalle (GH Profile), the original maintainer, stepped down from active support in March 2023. Since then, the project has been maintained through community contributions. The current effort, under the name FireORM24, focuses on updating the project with the latest security patches and new features to align with the latest Firebase advancements. The original project can be found here.
For more information on the motivations behind the project, you can read Willy's original introductory post on Medium. The API documentation is also available.
yarn add fireorm24 reflect-metadata #or npm install fireorm24 reflect-metadata
# note: the reflect-metadata shim is required
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
import serviceAccount from "../firestore.creds.json"; // Adjust path as necessary
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_PROJECT_ID.appspot.com",
messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
appId: "YOUR_APP_ID",
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
// Initialize Cloud Firestore and get a reference to the service
const db = getFirestore(app);
fireorm.initialize(db);
import { Collection } from 'fireorm24';
@Collection()
class Programmer {
id: string;
name: string;
language: string;
}
import { Collection, getRepository } from 'fireorm24';
@Collection()
class Programmer {
id: string;
name: string;
language: string;
}
const programmerRepository = getRepository(Programmer);
const willy = new Programmer();
willy.name = "Willy Ovale";
willy.language = "Typescript";
const programmerDocument = await programmerRepository.create(willy); // Create programmer
const mySuperProgrammerDocument = await programmerRepository.findById(programmerDocument.id); // Read programmer
mySuperProgrammerDocument.language = "Typescript, .NET";
await programmerRepository.update(mySuperProgrammerDocument); // Update programmer
await programmerRepository.delete(mySuperProgrammerDocument.id); // Delete programmer
Firestore supports complex data types such as GeoPoint and Reference. The integration of full support for these data types into the new FireORM project is currently in progress. This section will be updated with detailed information once the support is fully implemented.
In the meantime, you can utilize Class Transformer's @Type decorator for handling nested objects. For example, refer to the GeoPoint Example.
Currently, casting GeoPoints to a custom class requires latitude: number
and longitude: number
as public class fields. This limitation will be addressed in future updates.
git clone https://github.com/elersong/fireorm24.git
yarn # npm install
Fireorm has two types of tests:
yarn test # or npm test
yarn test:integration # or npm test:integration
To be able to run the integration tests you need to create a Firebase service account and declare some environment variables.
Test files must follow the naming convention *.test.ts
and use jest as the test runner.
This repo uses Conventional Commits as the commit messages convention.
This repo uses Semantic Release to automatically release new versions as soon as they land on master.
Commits must follow Angular's Git Commit Guidelines.
Supported commit types (taken from here):
yarn build:doc # or npm build:doc
Documentation is automatically deployed on each commit to master and is hosted in Github Pages in this link.
Have a bug or a feature request? Please visit the new issues page on the FireORM24 repository. To contribute, check the new issues page to find a problem you would like to solve. Additionally, you can review the old FireORM issues page to see if any requested features have not yet been reported to the new repository.
Pull requests are welcome!
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT Β© Willy Ovalle and Grey Elerson. See LICENSE for details.