{"id":18202457,"url":"https://github.com/janwuesten/firebase-typescript","last_synced_at":"2025-04-07T18:25:35.889Z","repository":{"id":64398482,"uuid":"573562125","full_name":"janwuesten/firebase-typescript","owner":"janwuesten","description":"Usefull Firebase Classes to use Firebase with TypeScript with a definied class pattern.","archived":false,"fork":false,"pushed_at":"2024-01-05T15:34:03.000Z","size":734,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T03:09:18.367Z","etag":null,"topics":["firebase","firebase-admin","firestore","react-native","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/janwuesten.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-02T19:07:57.000Z","updated_at":"2024-01-02T16:34:34.000Z","dependencies_parsed_at":"2023-12-21T19:48:32.188Z","dependency_job_id":"ac7df017-0adb-431f-8ec0-4b8241c07728","html_url":"https://github.com/janwuesten/firebase-typescript","commit_stats":{"total_commits":108,"total_committers":2,"mean_commits":54.0,"dds":0.0092592592592593,"last_synced_commit":"b7b9c6ad2cf24e5d0ea845eeade65c41a1137bea"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janwuesten%2Ffirebase-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janwuesten%2Ffirebase-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janwuesten%2Ffirebase-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janwuesten%2Ffirebase-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janwuesten","download_url":"https://codeload.github.com/janwuesten/firebase-typescript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247705646,"owners_count":20982473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["firebase","firebase-admin","firestore","react-native","typescript"],"created_at":"2024-11-03T10:04:03.395Z","updated_at":"2025-04-07T18:25:35.854Z","avatar_url":"https://github.com/janwuesten.png","language":"TypeScript","readme":"[![Publish npm package](https://github.com/janwuesten/firebase-typescript/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/janwuesten/firebase-typescript/actions/workflows/npm-publish.yml)\n[![Test npm package](https://github.com/janwuesten/firebase-typescript/actions/workflows/npm-test.yml/badge.svg)](https://github.com/janwuesten/firebase-typescript/actions/workflows/npm-test.yml)\n\n# Firebase for TypeScript\n\n## Introduction\nWhen working with Firebase and TypeScript creating Classes for Firestore Documents can be a bit annoying.\nAs there is not standard way of parsing and writing your Class to a Firestore Document, every project\nuses an different way.\n\nThe Firebase for TypeScript will change that by providing a standard way of using Classes that can then be stored into\nthe Firestore Database. It makes creating, reading and maintaining Firestore Document Classes easy and consistent across projects.\n\n## Installation\n\n### Installation\nThis installation method support firebase for web, firebase admin and firebase for react native by default.\n\n`npm install @janwuesten/firebase-typescript`\n\nKeep in mind that you still need to install the firebase sdk for that environment.\n[You can see more information in the Wiki](https://janwuesten.github.io/firebase-typescript/docs/getting-started/installation).\n\n## Basic usage example\n```ts\nimport { getFirestore, collection } from \"firebase/firestore\"\nimport { DocumentClass, DocumentClassDefineProps } from \"@janwuesten/firebase-typescript\"\n\nexport class Account extends DocumentClass {\n    username: string = \"\"\n    firstName: string | null = null\n    lastname: string | null = null\n\n    definition({ define, defineCollection, defineHandler }: DocumentClassDefineProps) {\n        // Define a prop\n        define(\"username\", \"string\")\n        define(\"firstName\", \"string\")\n        define(\"lastName\", \"string\")\n\n        // Define what collection will be used\n        defineCollection(() =\u003e collection(getFirestore(), \"account\"))\n\n        // Define the document class handler to set which firebase app is used\n        // and if this class if for web, admin or react native\n        // you can see example handlers for web, admin and react native in the wiki:\n        // https://janwuesten.github.io/firebase-typescript/docs/getting-started/handlers\n        defineHandler(new MyClassHandler())\n    }\n}\n```\n\n### Setting or creating a document\n```ts\nconst account = new Account()\naccount.username = \"MyUsername\"\nawait account.set()\n// Created document ID:\nconsole.log(account.id)\n```\n\n### Getting a document\n```ts\nconst account = new Account(\"document id\")\nif (await account.get()) {\n    console.log(\"Account does exist\")\n} else {\n    console.log(\"Account does not exist\")\n}\n```\n\n### Updating a document\n```ts\nconst account = new Account(\"document id\")\nawait account.get()\naccount.username = \"MyNewUsername\"\nawait account.update()\n// You can also use:\n// await account.set()\n```\n\n\n### Deleting a document\n```ts\nconst account = new Account(\"document id\")\nawait account.delete()\n```\n\nFor more information on how to use firebase-typescript with all its features visit the [documentation](https://janwuesten.github.io/firebase-typescript/docs/intro).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanwuesten%2Ffirebase-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanwuesten%2Ffirebase-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanwuesten%2Ffirebase-typescript/lists"}