In order to generate random numbers, hashes etc, as well as allow values to be derived from another value allow the defaultValue property to be a handler function which takes the current operation and assigns a value to it.
i.e...
// Member
const member = {
schema: {
name: {
[method]: { // i.e. 'post'
defaultValue(item) {
return `${item.firstName} ${item.lastName}`;
}
}
}
}
};
const dare = new Dare({models: {member}});
// Post
await dare.post('member', {
firstName: 'Andrew',
lastName: 'Dodson',
});
// # Generates the query...
// INSERT INTO member (firstName, lastName, name)
// VALUES ('Andrew', 'Dodson', 'Andrew Dodson');
In order to generate random numbers, hashes etc, as well as allow values to be derived from another value allow the
defaultValueproperty to be a handler function which takes the current operation and assigns a value to it.i.e...