vlquery can save your data too!
Let's create a simple book with a refrence to its author
const author = await db.author.find("<uuid>"); const book = new Book(); book.title = "My First Book!"; book.author = author; await book.create();
Alternatively to using .author
you could do this:
book.authorId = "<uuid>";
vlquery will add the new id of your record to it, so after calling create, you'll be able to use the new id!
Whenever your data need some refreshing, do this:
const book = await db.book.find("<uuid>"); book.title = "New Title"; await book.update();
When your data is no longer required, it can be deleted with this code. vlquery will check all references before you can delete the item!
const book = await db.book.find("<uuid>"); await book.delete();
If you are using an active column, this will only deactivate the row!
Records can be duplicated by using the createDuplicate
method on an entity
const book = await db.book.find("<uuid>"); const copy = book.createDuplicate(); copy.title += " (Copy)"; await copy.create(); console.log(book.title); // "My first book" console.log(copy.title) // "My first book (Copy)"