{"id":20850025,"url":"https://github.com/cristobalgvera/nestjs-firestore","last_synced_at":"2026-04-13T18:01:56.388Z","repository":{"id":172932152,"uuid":"649994240","full_name":"cristobalgvera/nestjs-firestore","owner":"cristobalgvera","description":"Use Firestore collections in a well known way, similar to how TypeORM lets you to handle your tables","archived":false,"fork":false,"pushed_at":"2023-06-21T03:03:53.000Z","size":199,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-29T15:39:30.057Z","etag":null,"topics":["collections","firebase","firestore","nestjs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cristobalgvera.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-06T05:22:42.000Z","updated_at":"2023-06-22T23:41:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"ade1d979-53b8-4271-9d13-d640ac62a38c","html_url":"https://github.com/cristobalgvera/nestjs-firestore","commit_stats":null,"previous_names":["cristobalgvera/nestjs-firestore"],"tags_count":4,"template":false,"template_full_name":"cristobalgvera/nestjs-lib-starter","purl":"pkg:github/cristobalgvera/nestjs-firestore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristobalgvera%2Fnestjs-firestore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristobalgvera%2Fnestjs-firestore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristobalgvera%2Fnestjs-firestore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristobalgvera%2Fnestjs-firestore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cristobalgvera","download_url":"https://codeload.github.com/cristobalgvera/nestjs-firestore/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristobalgvera%2Fnestjs-firestore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31764317,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collections","firebase","firestore","nestjs"],"created_at":"2024-11-18T03:07:45.079Z","updated_at":"2026-04-13T18:01:56.371Z","avatar_url":"https://github.com/cristobalgvera.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestJS Firestore\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://nestjs.com/\" target=\"blank\"\u003e\n    \u003cimg src=\"https://nestjs.com/img/logo-small.svg\" width=\"200\" alt=\"Nest Logo\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nThis project helps you to use your Firestore collections in a well known way,\nsimilar\\* to how TypeORM lets you to handle your tables.\n\nThe principal benefits are:\n\n- Model your collections using classes (similar on how ORMs works).\n- Simplify the testing of the Firestore SDK.\n\n_\\*This is NOT an ORM._\n\n## Installation\n\nIn order to install this package simply run the following command.\n\n```bash\nnpm install @cristobalgvera/nestjs-firestore\n```\n\n## Usage\n\nThe simplest way to use it is the following:\n\n1. Import the `FirestoreModule#forRoot` into your main module.\n\n   ```ts\n   import { FirestoreModule } from '@cristobalgvera/nestjs-firestore';\n   import { Module } from '@nestjs/common';\n\n   @Module({\n     imports: [\n       FirestoreModule.forRootAsync({\n         useFactory: (environmentService: EnvironmentService) =\u003e ({\n           // You can define custom properties here, see https://github.com/googleapis/nodejs-firestore\n           projectId: 'firebase-project-id',\n         }),\n       }),\n     ],\n   })\n   export class AppModule {}\n   ```\n\n1. Define your model (currently only classes are supported).\n\n   ```ts\n   export class User {\n     name: string;\n     age: number;\n   }\n   ```\n\n1. Import the `FirestoreModule#forFeature` into your feature module.\n\n   ```ts\n   import { FirestoreModule } from '@cristobalgvera/nestjs-firestore';\n   import { Module } from '@nestjs/common';\n   import { User } from './user.collection';\n\n   @Module({\n     imports: [\n       FirestoreModule.forFeature([\n         { collection: User, path: 'path-to-your-collection' },\n       ]),\n     ],\n   })\n   export class UserModule {}\n   ```\n\n1. Inject the collection into your services using the `InjectCollection` decorator\n   and the `FirestoreCollection` type. The `FirestoreCollection` needs a generic\n   class (soon type or interface too) in order to type your collection.\n\n   The `FirestoreCollection` is a wrapper on top of the `CollectionReference` type\n   provided by `@google-cloud/firestore`, so you can use the entire API, but it\n   will provide correct typing based in the collection class.\n\n   ```ts\n   import {\n     FirestoreCollection,\n     InjectCollection,\n   } from '@cristobalgvera/nestjs-firestore';\n   import { Injectable } from '@nestjs/common';\n   import { User } from './user.collection';\n\n   @Injectable()\n   export class UserService {\n     constructor(\n       @InjectCollection(User)\n       private readonly userCollection: FirestoreCollection\u003cUser\u003e,\n     ) {}\n\n     saveUser({ name, age }: SaveUserDto) {\n       return this.userCollection.add({ name, age });\n     }\n   }\n   ```\n\n1. Test it using the `getCollectionToken` to get the token used to inject the collection\n   in the service.\n\n   ```ts\n   import { TestBed } from '@automock/jest';\n   import {\n     FirestoreCollection,\n     getCollectionToken,\n   } from '@cristobalgvera/nestjs-firestore';\n   import { User } from './user.collection';\n   import { UserService } from './user.service';\n\n   describe('UserService', () =\u003e {\n     let underTest: UserService;\n     let userCollection: FirestoreCollection\u003cUser\u003e;\n\n     beforeEach(() =\u003e {\n       // Don't focus on how to create the context of the test\n       const { unit, unitRef } = TestBed.create(UserService).compile();\n       underTest = unit;\n\n       userCollection = unitRef.get(getCollectionToken(User)); // \u003c-- THIS IS THE IMPORTANT PART\n     });\n\n     /* Your tests here... */\n   });\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristobalgvera%2Fnestjs-firestore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcristobalgvera%2Fnestjs-firestore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristobalgvera%2Fnestjs-firestore/lists"}