diff --git a/packages/ra-cubicweb/src/index.ts b/packages/ra-cubicweb/src/index.ts index 1d25689923e66069cea213f9d5eb70fa882ae3bf_cGFja2FnZXMvcmEtY3ViaWN3ZWIvc3JjL2luZGV4LnRz..26c54b6e5e552a53614163610bdcc31d4046a89d_cGFja2FnZXMvcmEtY3ViaWN3ZWIvc3JjL2luZGV4LnRz 100644 --- a/packages/ra-cubicweb/src/index.ts +++ b/packages/ra-cubicweb/src/index.ts @@ -145,7 +145,20 @@ return Promise.resolve({ data: { ...data, id } }); }, updateMany: (_resource, _params) => Promise.reject("Not implemented"), - create: (_resource, _params) => Promise.reject("Not implemented"), + create: async (resource, { data }) => { + // FIXME create relations + const attributesUpdates: string[] = []; + Object.entries(data).forEach(([key, value]) => { + if (key in schema.etypes[resource]) { + attributesUpdates.push(`X ${key} ${JSON.stringify(value)}`); + } + }); + const result = await rqlClient.queryRows(` + INSERT ${resource} X: ${attributesUpdates.join(", ")} + `); + const eid = result[0][0]; + return Promise.resolve({ data: { ...data, id: eid } }); + }, delete: (_resource, _params) => Promise.reject("Not implemented"), deleteMany: (_resource, _params) => Promise.reject("Not implemented"), };