You can take a look on this one, this one is written in Typescript
Description: ts-datastore-orm targets to provide a strong typed and structural ORM feature for Datastore (Firestore in Datastore mode).
https://www.npmjs.com/package/ts-datastore-orm
import {BaseEntity, Batcher, Column, datastoreOrm, Entity, Transaction, DatastoreOrmDatastoreError, DatastoreOrmError} from "ts-datastore-orm";
@Entity({namespace: "testing", kind: "user", compositeIndexes: [{id: "desc"}, {string: "asc", ["object.name"]: "asc", __ancestor__: false}]})
export class User extends BaseEntity {
@Column({generateId: true})
public id: number = 0;
@Column()
public date: Date = new Date();
@Column({index: true})
public string: string = "";
@Column()
public number: number = 10;
@Column()
public buffer: Buffer = Buffer.alloc(1);
@Column()
public array: number[] = [];
@Column({excludeFromIndexes: ["object.name"]})
public object: any = {};
@Column()
public undefined: undefined = undefined;
@Column()
public null: null = null;
}
async function queryExamples() {
const [user1, requestResponse1] = await User.query().runOnce();
const [userList1, requestResponse2] = await User.findMany([1, 2, 3, 4, 5]);
const [userList2, requestResponse3] = await User.findMany({ancestor: user1, ids: [1, 2, 3, 4, 5]});
const [userList3, requestResponse4] = await User.query().run();
const user2 = User.create({id: 1});
const query = TaskGroup.query()
.filter("number", "=", 10)
.filterAny("anyColumn.name", ">", 5)
.setAncestor(user2)
.groupByAny("anyColumn.name")
.orderAny("anyColumn.name", {descending: true})
.offset(5)
.limit(10);
while (query.hasNextPage()) {
const [entities] = await query.run();
}
// stream
const stream = query.runStream()
.on("data", (entity) => {
//
})
.on("info", (info) => {
//
})
.on("error", (error) => {
//
})
.on("end", () => {
//
});
}