5
votes

Is there some high level ORM for nodejs datastore client library? Because it becoming really hard to maintain relatively small application when entities referencing and objects versioning takes place. Just interested, should I start write my own bicycle or someone already wrote something like that?

If not, maybe there some separate libraries to implemented appropriate referencing mechanism?

2
Datastore is not relational database, So Datastore dose not have JOIN. I guess that ORM like Ruby's Active Record is not appropriate for Datastore. - nshmura
@nshmura, Well, I'm don't want actual relational things here. But, instead a framework that already has all algorithms to handle references and relations between entities on code level, at least, because, datastore client library supports really limited functionality. I understand, that this is a low-level API, and because of this, I'm interested in something more high-level, that might cover business requirements easier and faster, with less efforts. - QuestionAndAnswer

2 Answers

6
votes

Check out gstore-node:

gstore-node is a Google Datastore entities modeling library for Node.js inspired by Mongoose and built on top of the @google-cloud/datastore library. It is not a replacement of @google-cloud/datastore but a tool built to help modeling Entities through Schemas and to help validating the data saved in the Datastore.

0
votes

You may try on this one, very well structure, written in Typescript.

https://www.npmjs.com/package/ts-datastore-orm

import {BaseEntity, Column, Entity} from "ts-datastore-orm";

@Entity({kind: "user"})
export class User extends BaseEntity {
    @Column({generateId: true})
    public id: number = 0;

    @Column({index: true})
    public total: number = 0;
}

async function main() {
    const user = User.create();
    await user.save();
    const id = user.id;
}