Adds a number of items to a collection.
bulkInsert() function returns a Promise that resolves after the items
have been added to the specified collection.
The Promise is rejected if the current user does not have create permissions
for the collection. Items are skipped if they include an
_id property whose
value matches an existing ID in the collection. Meaning,
overwrite an existing item in the collection.
options parameter to run
bulkInsert() from backend code without
checking for permissions or without its registered hooks.
When inserting items into a collection that has a reference field, set
the values of the reference fields to the referenced item's
_id value or
the entire referenced item object.
bulkInsert() function adds the following properties and values to the item
when it adds it to the collection:
_id: A unique identifier for the item with collection, if the item does not include one. You can optionally provide your own ID. Once an ID is assigned to an item it cannot be changed.
_createdDate: The date the item was added to the collection.
_updatedDate: The date the item was modified. When the item is first added, the
updatedDateare the same.
function maintains the structure of the specified object. For example,
objects that contain nested objects, Arrays, or Arrays with nested objects
are all added to the collection as defined.
The maximum size of an item that you can add to a collection is 200kb.
Note: Bulk operations are limited to 1000 items per function call.
function bulkInsert(collectionName: string, items: Array<Object>, [options: WixDataOptions]): Promise<WixDataBulkResult>
The name of the collection to add the item to.
The items to add.
An object with one or both of the following boolean properties: suppressAuth, suppressHooks.
Fulfilled - The results of the bulk insert. Rejected - The error that caused the rejection.
Was this helpful?