Building a CRUD Flow
This guide walks through building list, create, get, and delete flows using call:lancedb.
-
Create the database resource
Terminal window # Create a LanceDB resourcecurl -X POST http://localhost:3002/message \-H "Content-Type: application/json" \-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1,"params": {"name": "create_resource","arguments": {"name": "my-db", "namespace": "default","type_ref": "lancedb","config": {"db_path": "/data/my-app.lance"}}}}' -
Create the table (schema install)
namespace: defaultname: products-schemaversion: "1.0.0"enabled: truesteps:- name: create-tabletype: call:lancedbresource: my-dbconfig:operation: create_tablemode: create_if_not_existstable: productsschema:id: stringname: stringprice: stringcreated_at: stringthen: end -
List flow
namespace: defaultname: products-listversion: "1.0.0"enabled: truesteps:- name: querytype: call:lancedbresource: my-dbconfig:operation: querytable: productslimit: 100then: end -
Create flow
Input:
{ data: { id, name, price }, timestamp }namespace: defaultname: products-createversion: "1.0.0"enabled: truesteps:- name: inserttype: call:lancedbresource: my-dbconfig:operation: inserttable: productsrecords:- id: "${ .data.id }"name: "${ .data.name }"price: "${ .data.price }"created_at: "${ .timestamp }"then: end -
Get flow
Input:
{ id }namespace: defaultname: products-getversion: "1.0.0"enabled: truesteps:- name: querytype: call:lancedbresource: my-dbconfig:operation: querytable: productsfilter: "id = '${ .id }'"limit: 1then: end -
Delete flow
Input:
{ id }namespace: defaultname: products-deleteversion: "1.0.0"enabled: truesteps:- name: deltype: call:lancedbresource: my-dbconfig:operation: deletetable: productsfilter: "id = '${ .id }'"then: end
Calling from the UI
Section titled “Calling from the UI”The UI service calls these flows directly:
const result = await flows.execute('products-list', 'default');// Poll for completionconst status = await flows.status(instanceId);// status.output = { count: N, rows: [...] }