Quick start with Tento
This guide assumes familiarity with:
Step 1 - Install dependencies
npm
yarn
pnpm
bun
npm i @drizzle-team/tento
Step 2 - Setup connection variables
SHOPIFY_ACCESS_TOKEN=
SHOPIFY_SHOP_ID=
Step 3 - Declare schema file
import { metaobject } from '@drizzle-team/tento';
export const designer = metaobject({
name: "Designer",
type: "designer",
fieldDefinitions: (f) => ({
name: f.singleLineTextField({
name: "Title",
required: true,
validations: (v) => [v.min(1), v.max(50)],
}),
description: f.multiLineTextField({
name: "Description",
}),
website: f.url({
name: "Website",
}),
}),
});
Step 4 - Connect and Query the Shopify
import 'dotenv/config';
import '@shopify/shopify-api/adapters/web-api';
import * as schema from './db/schema';
import { createClient, tento } from '@drizzle-team/tento';
const client = tento({
client: createClient({
shop: process.env.SHOPIFY_SHOP_ID!,
headers: {
"X-Shopify-Access-Token": process.env.SHOPIFY_ACCESS_TOKEN!,
},
}),
schema,
});
async function main() {
await client.applySchema();
const createdDesigner = await client.metaobjects.designer.insert({
name: "John",
description: "John is designer",
website: "https://drizzle.team/",
});
console.log("New designer created!");
const designers = await client.metaobjects.designer.list({
first: 50
});
}