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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@theramagnoli/fire-base-model

v0.1.0

Published

a firestore orm

Readme

🔥-base-model

a lightweight, decorator-based firestore ORM for firebase. inspired by adonisjs's lucid ORM.

installation

npm install fire-base-model firebase

setup

initialize the library once, before any models are used.

import { initializeApp } from "firebase/app"
import { getFirestore } from "firebase/firestore"
import { initFireBaseModel } from "fire-base-model"

const app = initializeApp(firebaseConfig)
const db = getFirestore(app)

initFireBaseModel(db)

defining models

import { FireBaseModel, property } from "fire-base-model"

export class Goal extends FireBaseModel {
    static collectionName = "goals"

    @property name!: string
    @property description!: string
}

soft deletes & timestamps

export class Post extends FireBaseModel {
    static collectionName = "posts"
    static softDeletes = true
    static timestamps = true

    @property title!: string
    @property body!: string
}

querying

// fetch all
const goals = await Goal.all()

// find by id
const goal = await Goal.find("abc123")
const goal = await Goal.findOrFail("abc123")

// find by field
const goal = await Goal.findBy("name", "My Goal")

// create
const goal = await Goal.create({ name: "My Goal", description: "..." })

// update
goal.name = "Updated Name"
await goal.save()

// delete
await goal.delete()

// force delete (ignores soft deletes)
await goal.forceDelete()

query builder

const results = await Goal.query()
    .where("status", "==", "active")
    .orderBy("createdAt", "desc")
    .limit(10)
    .get()

// first result
const first = await Goal.query().where("name", "==", "My Goal").first()

// check existence
const exists = await Goal.query().where("name", "==", "My Goal").exists()

// count
const total = await Goal.query().where("status", "==", "active").count()

// pagination
const page = await Goal.query().paginate(10, lastId)
// page.data -> results
// page.meta.hasMore -> boolean
// page.meta.lastId -> cursor for next page

nested collections

export class Comment extends FireBaseModel {
    static collectionName = "comments"
    static mustHaveParent = true

    @property text!: string
}

const comments = await Comment.all(parentPost)
const comment = await Comment.find("abc123", parentPost)
await Comment.create({ text: "Hello" }, parentPost)

collection group queries

query across all subcollections with the same name, regardless of nesting.

const allComments = await FireBaseModelQueryBuilder.queryGroup
    .call(Comment)
    .where("text", "==", "Hello")
    .get()

mixins

import { FireBaseModel, property, type MixinConstructor } from "fire-base-model"

export function WithTimestamps<TBase extends MixinConstructor>(Base: TBase) {
    class Mixin extends Base {
        @property publishedAt?: Date
    }
    return Mixin
}

export class Post extends WithTimestamps(FireBaseModel) {
    static collectionName = "posts"

    @property title!: string
}

infer model type

strip methods and get just the data shape of a model.

import type { InferModelType } from "fire-base-model"

type GoalData = InferModelType<Goal>
// { id: string, name: string, description: string, createdAt?: Date, ... }

requirements

  • firebase >=10.0.0
  • typescript ^5.0.0
  • experimentalDecorators: true in your tsconfig.json for legacy decorators, or typescript 5+ standard decorators work out of the box.

license

MIT