{"id":50759066,"url":"https://github.com/phamngocduy98/node_flashdata_library","last_synced_at":"2026-06-11T08:01:59.523Z","repository":{"id":54162717,"uuid":"291612781","full_name":"phamngocduy98/node_flashdata_library","owner":"phamngocduy98","description":"Firebase Realtime Database Library | For NodeJS server with FirebaseAdminSdk","archived":false,"fork":false,"pushed_at":"2021-03-06T10:30:27.000Z","size":98,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-12T01:55:10.140Z","etag":null,"topics":["firebase","firebase-admin","firebase-admin-sdk","firebase-realtime","firebase-realtime-database","firebase-realtimedatabase","firestore-database","firestore-nodejs","realtime-database","realtime-database-firebase"],"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/phamngocduy98.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-31T04:18:58.000Z","updated_at":"2021-03-06T10:27:59.000Z","dependencies_parsed_at":"2022-08-13T08:00:55.164Z","dependency_job_id":null,"html_url":"https://github.com/phamngocduy98/node_flashdata_library","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/phamngocduy98/node_flashdata_library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phamngocduy98%2Fnode_flashdata_library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phamngocduy98%2Fnode_flashdata_library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phamngocduy98%2Fnode_flashdata_library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phamngocduy98%2Fnode_flashdata_library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phamngocduy98","download_url":"https://codeload.github.com/phamngocduy98/node_flashdata_library/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phamngocduy98%2Fnode_flashdata_library/sbom","scorecard":{"id":730488,"data":{"date":"2025-08-11","repo":{"name":"github.com/phamngocduy98/node_flashdata_library","commit":"ce828371be3fa9fce778c3dc1a49a69d746fcc60"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.2,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/4 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/cd_buid_publish.yml:1","Warn: no topLevel permission defined: .github/workflows/ci_merge_master.yml:1","Warn: no topLevel permission defined: .github/workflows/ci_pull_request.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/cd_buid_publish.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/cd_buid_publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/cd_buid_publish.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/cd_buid_publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci_merge_master.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/ci_merge_master.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci_merge_master.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/ci_merge_master.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci_pull_request.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/ci_pull_request.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci_pull_request.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/ci_pull_request.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci_pull_request.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/ci_pull_request.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci_pull_request.yml:50: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/ci_pull_request.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci_pull_request.yml:65: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/ci_pull_request.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci_pull_request.yml:69: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/ci_pull_request.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci_pull_request.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/ci_pull_request.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci_pull_request.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/phamngocduy98/node_flashdata_library/ci_pull_request.yml/main?enable=pin","Info:   0 out of  12 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"31 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-4g6q-77j7-vvjc","Warn: Project is vulnerable to: GHSA-7v5v-9h63-cj86","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-wm7h-9275-46v2","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-8cf7-32gw-wr33","Warn: Project is vulnerable to: GHSA-hjrf-2m68-5959","Warn: Project is vulnerable to: GHSA-qwph-4952-7xr6","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-5rrq-pxf6-6jx5","Warn: Project is vulnerable to: GHSA-8fr3-hfg3-gpgp","Warn: Project is vulnerable to: GHSA-gf8q-jrpm-jvxq","Warn: Project is vulnerable to: GHSA-2r2c-g63r-vccr","Warn: Project is vulnerable to: GHSA-cfm4-qjh2-4765","Warn: Project is vulnerable to: GHSA-x4jg-mjrx-434g","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-g954-5hwp-pp24","Warn: Project is vulnerable to: GHSA-h755-8qp9-cq85","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T14:16:03.392Z","repository_id":54162717,"created_at":"2025-08-22T14:16:03.393Z","updated_at":"2025-08-22T14:16:03.393Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34188272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["firebase","firebase-admin","firebase-admin-sdk","firebase-realtime","firebase-realtime-database","firebase-realtimedatabase","firestore-database","firestore-nodejs","realtime-database","realtime-database-firebase"],"created_at":"2026-06-11T08:01:55.776Z","updated_at":"2026-06-11T08:01:59.518Z","avatar_url":"https://github.com/phamngocduy98.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FlashData - Realtime Database\n![npm](https://img.shields.io/npm/v/@phamngocduy98/flashdata)\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/phamngocduy98/node_flashdata_library/Coverage%20check)\n![npm](https://img.shields.io/npm/dt/@phamngocduy98/flashdata)\n![node-lts (scoped)](https://img.shields.io/node/v-lts/@phamngocduy98/flashdata)\n![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/@phamngocduy98/flashdata/dev/typescript)\n![GitHub package.json dependency version (prod)](https://img.shields.io/github/package-json/dependency-version/phamngocduy98/node_flashdata_library/firebase-admin)\n```\nnpm i @phamngocduy98/flashdata\n```\n\nA realtime database library that making it easier to CRUD data with typescript\n\n## How to use\n\n### 0. You need to know before using this library:\n\nWhile realtime database stores data in a JSON tree. It can be structured by documents and collections like Firebase Firestore after flattening the data structure.  \nSo, your data is now collections and documents :D\n\n### 1. Define document type class\n\nDefine properties of your document by extending `DocumentData` class\n\n```typescript\nimport {DocumentData} from \"@phamngocduy98/flashdata\";\n\nexport class User extends DocumentData {\n    name: string;\n    avatarUrl: string;\n\n    constructor(name: string, avatarUrl: string) {\n        super();\n        this.name = name;\n        this.avatarUrl = avatarUrl;\n    }\n}\n```\n\n### 2. Define nested document:\n\nIf you have a `Room` that contains a `State` document:\n\n```typescript\nexport class Room extends DocumentData {\n    @NestedDocument(State)\n    state!: State;\n\n    constructor(state: State) {\n        super();\n        this.state = state;\n    }\n}\n```\n\n### 3. Define collections:\n\nFor example, you have a root collection whose name is `users`\nUse `@Collection` decorator tells the library what is the type of collection's document.\n\n```typescript\nimport {Collection, Database, RealtimeCollection} from \"@phamngocduy98/flashdata\";\nimport {User} from \"./\";\n\nexport class MyDatabase extends Database {\n    @Collection(User)\n    users!: RealtimeCollection\u003cUser\u003e;\n}\n```\n\nThen you have subcollection, here is the example how to define a subcollection:\n\n```typescript\nimport {Collection, DocumentData} from \"@phamngocduy98/flashdata\";\nimport {Player} from \"./Player\";\n\nexport class State extends DocumentData {\n    @Collection(Player)\n    players!: Map\u003cstring, Player\u003e;\n\n    constructor(public roomId: string, players: Map\u003cstring, Player\u003e) {\n        super();\n        this.players = players;\n    }\n}\n```\n\nOh! Did you see the difference here?  \nCollection in Database is kept in type of RealtimeCollection while\nSubcollection in State document is stored as Map.  \nThe library convert subcollection into map to make it easier to read data.\n\n### 4. Define a Map:\n\nMap is just a collection of primitives type instead of document. Here is example how to use it:\n\n```typescript\nexport class State extends DocumentData {\n    @MapArray(\"number\")\n    setup!: Map\u003cstring, number\u003e;\n    constructor(setup: Map\u003cstring, number\u003e) {\n        super();\n        this.setup = setup;\n    }\n}\n```\n\n### 5. CRUD\n\nFor example, you have a root `rooms` collection, a room contains a nested `State` document.\nThen inside `State` there is a subcollection `players`.\n\n##### Create\n\n```typescript\nlet testRoomDoc: RealtimeDocument\u003cRoom\u003e = await db.rooms.create(\n    \"test_room\",\n    new Room(\n        new State(\n            \"111\",\n            new Map([\n                [\"1\", 1],\n                [\"2\", 2]\n            ]),\n            new Map\u003cstring, Player\u003e([[\"duy1\", new Player(\"duy1\", \"Duy\", \"avatar\", true)]])\n        )\n    )\n);\n```\n\n##### Read\n\n```typescript\ntestRoomDoc = await db.rooms.child(\"test_room\");\nlet room: Room = await testRoomDoc.value();\nconsole.log(room);\n```\n\n##### Nested document\n\n```typescript\nlet stateDoc: RealtimeDocument\u003cState\u003e = testRoomDoc.nested\u003cState\u003e(\"state\")!;\nlet state: State = await stateDoc.value();\nconsole.log(state);\n```\n\n##### Sub collection:\n\n```typescript\nlet players: RealtimeCollection\u003cPlayer\u003e = stateDoc.subCollection\u003cPlayer\u003e(\"players\");\nlet playerDoc: RealtimeDocument\u003cPlayer\u003e = players.child(\"duy1\"); // as Map\nplayerDoc = players.getAt(0); // use collection as Array (while document are sorted by id and id is increment overtime)\nplayers.set(\"player1\", new Player()); // set value of key player1\nplayers.add(new Player()); // create using auto key id\nlet allPlayers: Map\u003cstring, Player\u003e = await players.children(); // get all\nplayers.clearCollection(); // delete all collection data\n```\n\n##### Map\n\n```typescript\nlet setup: RealtimeMap\u003cnumber\u003e = stateDoc.subMap(\"setup\");\nawait setup.clear();\nawait setup.set(\"setup1\", 2); // add (or overwrite) at key = \"setup1\" with value \"2\"\nlet setup1 = setup.get(\"setup1\");\nawait setup.remove(\"setup1\"); // remove a key\n\nawait setup.add(1); // add with auto ID (or use a an array)\nlet setup0 = setup.getAt(0); // if you use map as an array\nawait setup.removeAt(0); // remove if you use map as an array\n```\n\n##### Get a deep item from path:\n\n```typescript\nplayerDoc = db.getChild(\"rooms/test_room/state/players/duy1\") as RealtimeDocument\u003cPlayer\u003e;\n```\n\n##### Get root / parent:\n\n```typescript\n// get root:\nplayerDoc.root;\n// get parent:\nplayerDoc.parent;\n```\n\n##### UPDATE:\n\n```typescript\ntestRoomDoc.update({\n    state: {\n        roomId: \"222\"\n    }\n});\n```\n\n##### DELETE:\n\n```typescript\ntestRoomDoc.delete();\n```\n\n##### SET:\n\noverwrite (the same as delete() then update())\n\n```typescript\ntestRoomDoc.set(new Room());\n```\n\n### Linking support like FlashStore\n\nComing soon in the next update.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphamngocduy98%2Fnode_flashdata_library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphamngocduy98%2Fnode_flashdata_library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphamngocduy98%2Fnode_flashdata_library/lists"}