Sometimes we have a json string containing the list of objects or
values to be inserted in the collection. In these cases it is better
to pass the entire string to the engine than to have to parse and
separate the values to be passed one by one to the engine.
So we could have a variation in the INSERT statement to accept a list
of values.
Then we have the first statement to insert a single value at a time
and the second one to pass a list:
INSERT INTO collection VALUE value
INSERT INTO collection VALUES [value1, value2, value3]
Example:
1. Using one value at a time:
INSERT INTO contacts VALUE {name: "John", email: "
a...@email.org"}
INSERT INTO contacts VALUE {name: "Mary", email: "
ma...@email.org"}
INSERT INTO contacts VALUE {name: "Billy", email: "
bi...@email.org"}
2. Passing the list to the engine:
INSERT INTO contacts VALUES [{name: "John", email: "
jo...@email.org"},
{name: "Mary", email: "
ma...@email.org"},
{name: "Billy", email: "
bi...@email.org"}
]
In this last case the engine may to insert 3 values to the collection.
In this case the last_insert_id function (if it should exist) can
return the id of the first one, or it can return an array with the
ids.
Or we could have 2 functions:
last_insert_id: return a 64 bit integer
last_insert_ids: return a json string containing a list with the ids.