ts-datastore-orm (v2.0.9) is a TypeScript ORM for Google Cloud Datastore (Firestore in Datastore mode). It provides strong typing, decorators for entity definition, and features like composite indexes, hooks (BeforeInsert, AfterLoad, etc.), and CRUD operations. It has zero runtime dependencies but requires @google-cloud/datastore v5+. Development is active with releases on npm. Key differentiators: type-safe, decorator-based, supports transactions, composite indexes, and lifecycle hooks, with no significant overhead vs native SDK.
npm install ts-datastore-ormNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Define a User entity with auto-generated ID, create a connection, insert, find, update, and delete a record.
Add default values or use `!` after property name, e.g., `public name!: string`.
Always explicitly set namespace in the @Entity decorator, e.g., @Entity({ namespace: 'my-app', kind: 'User' }).Use ESM imports: `import { ... } from 'ts-datastore-orm'`.Ensure `_id` is typed as `number` and initialized to 0 (or `!`).
Use 'asc' or 'desc' for index direction.
Replace `userRepo.findById(123)` with `userRepo.findOne({ _id: 123 })`.Add 'experimentalDecorators': true to compilerOptions in tsconfig.json.
Ensure your project is ESM (type: 'module' in package.json, or use .mjs extension) and use import statements instead of require().
Run: npm install @google-cloud/datastore@latest
Check that keyFilename points to a valid service account JSON file or that clientEmail/privateKey are correct.