Skip to content
Snippets Groups Projects
Commit 26c54b6e5e55 authored by Frank Bessou's avatar Frank Bessou :spider_web:
Browse files

feat: implement create method

parent 1d25689923e6
No related branches found
No related tags found
No related merge requests found
...@@ -145,7 +145,20 @@ ...@@ -145,7 +145,20 @@
return Promise.resolve({ data: { ...data, id } }); return Promise.resolve({ data: { ...data, id } });
}, },
updateMany: (_resource, _params) => Promise.reject("Not implemented"), 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"), delete: (_resource, _params) => Promise.reject("Not implemented"),
deleteMany: (_resource, _params) => Promise.reject("Not implemented"), deleteMany: (_resource, _params) => Promise.reject("Not implemented"),
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment