save
Create or update an instance.
connection.save( instance )
Creates or updates an instance using the connection
by calling
createData or updateData.
// create an instance
const instance = new Type();
// create it with the connection
connection.save( instance ).then( function( instance ) {
// change the instance
instance.prop = "NEW VALUE";
// update it with the connection
connection.save( instance ).then( function( instance ) {
} );
} );
The choice of createData or updateData is made by the result of isNew.
Note that can/map adds save
to the instance
type's prototype.
Parameters
- instance
{Instance}
:A typed instance.
Returns
{Promise<Instance>}
:
Returns a promise that resolve with created or updated instance if createData or updateData is resolved. The promise is rejected if createData or updateData is rejected.