const collectionName = 'Students';
domo.put(`/domo/datastores/v2/collections/${collectionName}/documents/bulk`, [
{
id: '402778f6-bc8d-4aa5-a581-e08e3fc98c05',
content: {
name: 'Harry Potter',
house: 'Gryffindor',
wand: { wood: 'holly', core: 'phoenix feather', length: 11 },
courses: ['Defense Against the Dark Arts', 'Potions', 'Transfiguration'],
prefect: false
}
},
{
id: 'dd363c89-60d2-4f70-89cb-c3c175be625b',
content: {
name: 'Hermione Granger',
house: 'Gryffindor',
wand: { wood: 'vine', core: 'dragon heartstring', length: 10.75 },
courses: ['Potions', 'Transfiguration', 'Arithmancy', 'Care of Magical Creatures'],
prefect: true
}
},
{
content: {
name: 'Ron Weasley',
house: 'Gryffindor',
wand: { wood: 'willow', core: 'unicorn hair', length: 14 },
courses: ['Defense Against the Dark Arts', 'Potions', 'Divination']
}
}
]).then(result => console.log(result));
{
"Updated": 2,
"Created": 1
}Upsert Documents in Bulk
Update existing documents or create new ones in bulk. Documents with a matching id are updated; documents without a matching id are created. Each document is limited to 2 MB.
PUT
/
domo
/
datastores
/
v2
/
collections
/
{collectionName}
/
documents
/
bulk
const collectionName = 'Students';
domo.put(`/domo/datastores/v2/collections/${collectionName}/documents/bulk`, [
{
id: '402778f6-bc8d-4aa5-a581-e08e3fc98c05',
content: {
name: 'Harry Potter',
house: 'Gryffindor',
wand: { wood: 'holly', core: 'phoenix feather', length: 11 },
courses: ['Defense Against the Dark Arts', 'Potions', 'Transfiguration'],
prefect: false
}
},
{
id: 'dd363c89-60d2-4f70-89cb-c3c175be625b',
content: {
name: 'Hermione Granger',
house: 'Gryffindor',
wand: { wood: 'vine', core: 'dragon heartstring', length: 10.75 },
courses: ['Potions', 'Transfiguration', 'Arithmancy', 'Care of Magical Creatures'],
prefect: true
}
},
{
content: {
name: 'Ron Weasley',
house: 'Gryffindor',
wand: { wood: 'willow', core: 'unicorn hair', length: 14 },
courses: ['Defense Against the Dark Arts', 'Potions', 'Divination']
}
}
]).then(result => console.log(result));
{
"Updated": 2,
"Created": 1
}