[英]Google Cloud Datastore ORM
nodejs 數據存儲客戶端庫是否有一些高級 ORM? 因為當實體引用和對象版本控制發生時,維護相對較小的應用程序變得非常困難。 只是有興趣,我應該開始寫我自己的自行車還是有人已經寫過類似的東西?
如果沒有,也許有一些單獨的庫來實現適當的引用機制?
查看gstore-node :
gstore-node 是 Node.js 的 Google Datastore 實體建模庫,受 Mongoose 啟發,構建在 @google-cloud/datastore 庫之上。 它不是 @google-cloud/datastore 的替代品,而是一種工具,旨在幫助通過 Schemas 對實體建模並幫助驗證保存在 Datastore 中的數據。
你可以試試這個用 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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.