{"id":16788843,"url":"https://github.com/narumincho/typed-firestore","last_synced_at":"2025-04-05T09:12:31.405Z","repository":{"id":36469534,"uuid":"226198927","full_name":"narumincho/typed-firestore","owner":"narumincho","description":"stronger type for @firebase/firestore-types","archived":false,"fork":false,"pushed_at":"2023-06-29T14:32:02.000Z","size":82,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T18:51:15.174Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/narumincho.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-05T22:20:57.000Z","updated_at":"2025-02-07T09:00:05.000Z","dependencies_parsed_at":"2025-02-10T18:11:15.402Z","dependency_job_id":"d3b2023d-9ea9-46f7-b19f-50854cf9f0fd","html_url":"https://github.com/narumincho/typed-firestore","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narumincho%2Ftyped-firestore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narumincho%2Ftyped-firestore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narumincho%2Ftyped-firestore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narumincho%2Ftyped-firestore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/narumincho","download_url":"https://codeload.github.com/narumincho/typed-firestore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312086,"owners_count":20918344,"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":[],"created_at":"2024-10-13T08:25:01.288Z","updated_at":"2025-04-05T09:12:31.372Z","avatar_url":"https://github.com/narumincho.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typed-firestore\n\n[![npm version](https://badge.fury.io/js/typed-firestore.svg)](https://badge.fury.io/js/typed-firestore)\n[![NPM](https://nodei.co/npm/typed-firestore.png)](https://nodei.co/npm/typed-firestore/)\n\nstronger type declaration for firebase firestore.\n\n[typed-admin-firestore](https://github.com/narumincho/typed-admin-firestore)\n\n## client\n\n```ts\nimport * as firebase from \"firebase/app\";\nimport \"firebase/firestore\";\nimport type * as typedFirestore from \"typed-firestore\";\n\nfirebase.initializeApp({...});\n\nconst firestoreInstance = (firebase.firestore() as unknown) as f.Firestore\u003c{\n  user: { key: UserId; value: User; subCollections: {} };\n  music: { key: MusicId; value: Music; subCollections: {} };\n  project: {\n    key: ProjectId;\n    value: Project;\n    subCollections: {\n      data:\n        | {\n            key: \"Body\";\n            value: { text: string };\n            subCollections: {};\n          }\n        | {\n            key: \"Comments\";\n            value: Comments;\n            subCollections: {};\n          };\n    };\n  };\n}\u003e;\n\ntype UserId = string \u0026 { _userId: never };\n\ntype User = {\n  name: string;\n  age: number;\n  openIdConnect: {\n    providerName: string;\n    idInProvider: string;\n  };\n  likedMusics: Array\u003cMusicId\u003e;\n  createdAt: firestore.Timestamp;\n};\n\ntype MusicId = string \u0026 { _musicId: never };\n\ntype Music = {\n  title: string;\n  artist: UserId;\n};\n\ntype ProjectId = string \u0026 { _projectId: never };\n\ntype Project = {\n  name: string;\n  createdBy: UserId;\n};\n\ntype Comments = {\n  comments: ReadonlyArray\u003c{\n    body: string;\n    createdBy: UserId;\n    createdAt: firestore.Timestamp;\n  }\u003e;\n};\n\n(async () =\u003e {\n  const userQuerySnapshotArray = await firestoreInstance\n    .collection(\"user\")\n    .where(\"age\", \"\u003c=\", 20)\n    .get();\n\n  for (const userQueryDocumentSnapshot of userQuerySnapshotArray.docs) {\n    const data = userQueryDocumentSnapshot.data();\n    console.log(\"name\", data.name); // Type hint !!!!!\n    console.log(\"providerName\", data.openIdConnect.providerName); // Type hint !!!!!\n\n    for (const likedMusicId of data.likedMusics) {\n      firestoreInstance.collection(\"music\").doc(likedMusicId); // no error !!!\n      firestoreInstance.collection(\"user\").doc(likedMusicId); // error !!!\n    }\n  }\n\n  const commentDoc = await firestoreInstance\n    .collection(\"project\") // autocomplete\n    .doc(\"6b9495528e9a12186b9c210448bdc90b\" as ProjectId)\n    .collection(\"data\") // autocomplete\n    .doc(\"Comments\") // autocomplete\n    .get(); // returns DocumentSnapshot of Comments\n})();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnarumincho%2Ftyped-firestore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnarumincho%2Ftyped-firestore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnarumincho%2Ftyped-firestore/lists"}