Class: Upsert


Built.Upsert is a helper module for performing upsert operations on group fields(fields inside a group field).

new Upsert(data){Upsert}

upsert.js, line 5
Instances created using Built.Upsert can placed against a field uid on which upsert operations are to be performed.
Name Type Description
data JSONObject | Array Single or Array of plain JavaScript object(s). Each object should contain a 'condition' key specifying the upsert condition(s) and a 'replacement' key specifying the upsert(s).
//'blt5d4sample2633b' is a dummy Application API key
// Class('class_name').Object returns a Object constructor
// 'project' is a uid of a class on Backend  
// 'person' is a reference field in 'employee' group. 
// If a person with name 'John' and age 24 is to be searched
// If such a person is found rename him to 'Jack' with proffession set to 'developer' else
// create a new object with these details
var upsertOp = Built.Upsert([{
   condition: {
      name: 'John',
      age: 24
   replacement: {
      name: 'Jack',
      age: 24,
      proffession: 'developer'
var employee = Built.Group('team', {
   employees: upsertOp,
   emp_id: 'emp123'
var app = Built.App('blt5d4sample2633b');
var project = app.Class('project').Object();
project = project.addGroup(employee)
.then(function(project) {