Class: GroupMultiple

GroupMultiple

A Group is special type of field in Built.io Backend. The reason its named such is that its a set of fields grouped together. Each group field has its own schema and can contain sub-groups. GroupMultiple should be used when a group field is marked as 'multiple'.

new GroupMultiple(fieldUid, data){GroupMultiple}

group-multiple.js, line 5
This should be used to represent a 'group field' which is marked as multiple in your class. This representation can then be passed to methods that accept a Built.GroupMultiple structure as argument.
Name Type Description
fieldUid String The Uid of the field in your class schema.
data Array Can be 1] Plain JavaScript array representing intial values 2] Instance of Built.Group (sub-group) 3] Instance of Built.GroupMultiple (sub-group)
Deprecated
  • Yes
Example

Constructor accepting plain JavaScript Object

var person = Built.GroupMultiple('person', [{ name: 'John', age: 22 }, { name: 'Sam', age: 19 }]); console.log(person.toJSON())

Constructor accepting instance of 'dummy' Built.Group

// In the above example we used plain JavaScript array to represent group's data. // Instead of this we can create dummy Built.Group instance and pass them // to Built.GroupMultiple. To create a dummy group specify fieldUid as '$dummy' var dummyGrp = Built.Group('$dummy', { name: 'John', age: 22 }) // We can take advantage of methods defined on Built.Group dummyGroup = dummyGroup.addCondition('address', { city: 'Mumbai' }) var person = Built.GroupMultiple('person', [dummyGroup]) console.log(person.toJSON())

Constructor accepting instance of Built.Group

// To construct structure in which a group field marked multiple contains a sub-groups use syntax shown below var mumbai = Built.Group('address', { city: 'Mumbai', state: 'Maharashtra' }); var surat = Built.Group('address', { city: 'Surat', state: 'Gujrat' }); var person = Built.GroupMultiple('person', [mumbai, surat]); console.log(person.toJSON())

Constructor accepting instance of Built.GroupMultiple

// To construct structure in which a group field marked multiple contains a sub-groups marked multiple use syntax shown below var developers = Built.GroupMultiple('developers', { name: 'John', profile: 'JavaScript Developer' }, { name: 'Sam', profile: 'Java Developer' }]); var devops = Built.GroupMultiple('devops', [{ name: 'Crystal', profile: 'AWS' }, { name: 'Jack', profile: 'Azur' }]); // Built.Mixin should be used to mix 2 or more Built.Group or Built.GroupMultiple together var employee = Built.GroupMultiple('employee', [Built.Mixin(developers, devops)]); console.log(employee.toJSON())

Methods

pop(){GroupMultiple}

group-multiple.js, line 139
This method is similar to Array.prototype.pop().
Example
// 'blt5d4sample2633b' is a dummy Application API key
var pune = Built.Group('city', {
   name: 'Pune'
})
var mumbai = Built.Group('city', {
   name: 'Mumbai'
})
var address = Built.GroupMultiple('address', [mumbai, pune]);
address = address.pop();
console.log(address.toJSON())

push(element){GroupMultiple}

group-multiple.js, line 108
This method is similar to Array.prototype.push.
Name Type Description
element object | Built.Group | Built.GroupMultiple Element to be pushed
Example

Pushing a Plain JavaScript object

// 'blt5d4sample2633b' is a dummy Application API key var person = Built.GroupMultiple('person',[{ name:'John' }]); person = person.push({ name: 'Jack' });

Pushing Built.Group instance in Built.GroupMultiple

// 'blt5d4sample2633b' is a dummy Application API key var pune = Built.Group('city', { name:'Pune' }) var mumbai = Built.Group('city', { name:'Mumbai' }) var address = Built.GroupMultiple('address',[mumbai]); address = address.push(pune); console.log(address.toJSON())

shift(){GroupMultiple}

group-multiple.js, line 160
This method is similar to Array.prototype.shift().
Example
// 'blt5d4sample2633b' is a dummy Application API key
var pune = Built.Group('city', {
   name: 'Pune'
})
var mumbai = Built.Group('city', {
   name: 'Mumbai'
})
var address = Built.GroupMultiple('address', [mumbai, pune]);
address = address.shift();
// Removes 'mumbai' from address
console.log(address.toJSON())

unshift(element){GroupMultiple}

group-multiple.js, line 182
This method is similar to Array.prototype.unshift().
Name Type Description
element object | Built.Group | Built.GroupMultiple Element to be pushed
Example
// 'blt5d4sample2633b' is a dummy Application API key
var pune = Built.Group('city', {
   name: 'Pune'
})
var mumbai = Built.Group('city', {
   name: 'Mumbai'
})
var address = Built.GroupMultiple('address', [mumbai]);
address = address.unshift(pune);
console.log(address.toJSON())