.insert(map: objectOrPointer, ...othersPropertyNames: pointer[])
The insert builder factory can be used with either an object or a list of property strings. You use it with a list of strings to define the columns of you insert query. You'll need therefore to supply some values later with values method
sh
.insert('id', 'first_name', 'last_name')
.into('users')
.values({id:42, first_name:'Laurent', last_name:'Renard'})
.build();
// > { text: 'INSERT INTO "users" ( "id", "first_name", "last_name" ) VALUES
// ( 42, 'Laurent', 'Renard' )',
// values: [] }
The version with an object map is simply equivalent to a call with a list of strings whose values are the keys of the object and then a call to values with the object values as query values. It will likely be more convenient if you wish to insert a single row.
sh
.insert({id: 42, first_name: 'Laurent', last_name: 'Renard'})
.into('users')
.build();
// is equivalent to
sh
.insert('id', 'first_name', 'last_name')
.into('users')
.values({id: 42, first_name: 'Laurent', last_name: 'Renard'})
.build();
// > { text: 'INSERT INTO "users" ( "id", "first_name", "last_name" )
// VALUES ( 42, 'Laurent', 'Renard' )',
// values: [] }