Skip to content

Instantly share code, notes, and snippets.

@brettneese
Created November 30, 2022 21:54
Show Gist options
  • Save brettneese/b1106e593485af68940b5ed515f6785b to your computer and use it in GitHub Desktop.
Save brettneese/b1106e593485af68940b5ed515f6785b to your computer and use it in GitHub Desktop.
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