npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fireorm24

v0.2.0

Published

Extended version of fireorm, the ORM for Firestore

Downloads

27

Readme

🔥 FireORM24 🔥

NPM Version Build Status Typescript lang All Contributors License

Introduction

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.

Usage

  1. Install the npm package:
yarn add fireorm24 reflect-metadata #or npm install fireorm24 reflect-metadata

# note: the reflect-metadata shim is required
  1. Initialize your Firestore application:
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);
  1. Create your Firestore models:
import { Collection } from 'fireorm24';

@Collection()
class Programmer {
  id: string;
  name: string;
  language: string;
}
  1. Manage your Firestore data with ease!
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

Firebase Complex Data Types

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.

Current Workaround

In the meantime, you can utilize Class Transformer's @Type decorator for handling nested objects. For example, refer to the GeoPoint Example.

Limitations

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.

Development

Initial Setup

  1. Clone the project from github:
git clone https://github.com/elersong/fireorm24.git
  1. Install the dependencies:
yarn # npm install

Testing

Fireorm has two types of tests:

  • Unit tests: yarn test # or npm test
  • Integration tests: 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.

Committing

This repo uses Conventional Commits as the commit messages convention.

Release a new version

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):

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing or correcting existing tests
  • chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
  • To release a new version to npm, first we have to create a new tag:
npm version [ major | minor | patch ] -m "Relasing version"
git push --follow-tags
  • Then we can publish the package to npm registry:
npm publish
  • To deploy the documentation:
yarn deploy:doc # or npm deploy:doc

Documentation

  • Fireorm uses typedoc to automatically build the API documentation, to generate it:
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.

Contributing

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!

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT © Willy Ovalle and Grey Elerson. See LICENSE for details.