deep-foundation / deeplinks

https://discord.gg/deep-foundation
The Unlicense
14 stars 9 forks source link

`deep.value` #243

Open Konard opened 1 year ago

Konard commented 1 year ago

Duplicated patterns found:

if (min) deep.update({ link_id: min?.id }, { value: t }, { table: 'numbers' });
else deep.insert({ type_id: Min, from_id: link.id, to_id: link.id, number: { data: { value: t } } });
if (max) deep.update({ link_id: max?.id }, { value: t }, { table: 'numbers' });
else deep.insert({ type_id: Max, from_id: link.id, to_id: link.id, number: { data: { value: t } } });

By link id

deep.value(linkId, value); // set value by linkId
deep.value(linkId) // get value by linkId

By link object

const link = { id: ... }; // existing link
const link = { type_id: ... }; // link pattern/template to be inserted

deep.value(link, value); // set value by by link object (allows make update or insert) 
deep.value(link) // get value by link object

Or this should be a part of link's IUD?