-
-
Save brettneese/b1106e593485af68940b5ed515f6785b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Entity, EntityItem, CreateEntityItem } from "electrodb"; | |
import { randomUUID } from "crypto"; | |
import { table, client } from "../config"; | |
async function execute() { | |
const entity = new Entity( | |
{ | |
model: { | |
entity: "device", | |
version: "1", | |
service: "DeviceService", | |
}, | |
attributes: { | |
id: { | |
type: "string", | |
set: () => randomUUID(), | |
required: true, | |
readOnly: true | |
}, | |
name: { | |
type: "string", | |
}, | |
}, | |
indexes: { | |
id: { | |
pk: { | |
field: "pk", | |
composite: ["id"], | |
}, | |
}, | |
}, | |
}, | |
{ table, client } | |
); | |
const data = { | |
name: "blah", | |
}; | |
const item = await entity.create(data).go(); | |
} | |
execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment