This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var securityToken = '<YOUR SECURITY TOKEN>'; | |
var username = '<YOUR USERNAME>'; | |
var password = '<YOUR PASSWORD>' + securityToken; | |
var consumerKey = '<YOUR CONSUMER KEY>'; | |
var consumerSecret = '<YOUR CONSUMER SECRET>'; | |
var tokenResponse = session.fetchUrlSync( | |
'https://login.salesforce.com/services/oauth2/token', { | |
method : 'POST', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gets a MOAT instance. | |
var moat = require('moat'); | |
// Initializes a new context. | |
var context = moat.init(); | |
// Gets a session object. | |
var session = context.session; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gets a UID of an object to be fetched. | |
var uid = 'an-identifier-for-object'; | |
var myArrayTypeMapper = | |
session.newModelMapperStub('MyArrayType'); | |
myArrayTypeMapper.findByUid(uid, { | |
success : function(result) { | |
if (result.array) { | |
var entity = result.array[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myArrayTypeMapper = | |
session.newModelMapperStub('MyArrayType'); | |
myArrayTypeMapper.findAllUids({ | |
success : function(result) { | |
for (var i = 0; i < result.array.length; i++) { | |
var uid = result.array[i]; | |
// do something | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myArrayTypeMapper = | |
session.newModelMapperStub('MyArrayType'); | |
myArrayTypeMapper.count({ | |
success : function(result) { | |
if (result.count > 100) { | |
// do something | |
... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prepares an update operation. | |
var myArrayTypeMapper = | |
session.newModelMapperStub('MyArrayType'); | |
// Creates or retrieves a model object | |
// obj.uid is automatically assigned | |
var obj = myArrayTypeMapper.newModelStub(); | |
obj.myProperty = 'myValue'; | |
obj.myIntProperty = 12345; | |
obj.myBooleanProperty = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gets a UID | |
var uid = ...; | |
// Prepares an update operation. | |
var myArrayTypeMapper = | |
session.newModelMapperStub('MyArrayType'); | |
// Enqueues the remove operation | |
myArrayTypeMapper.remove(uid, { | |
error : function(type, code) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mySingletonTypeMapper = | |
session.newModelMapperStub('MySingletonType'); | |
var obj = mySingletonTypeMapper.newModelStub(uid); | |
obj.doIt(session, 'param_data', { | |
success : function(reuslt) { | |
if (result.async) { | |
.... | |
} else { | |
.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gets a UID of an object to be fetched. | |
var uid = 'an-identifier-for-object'; | |
var myArrayTypeMapper = | |
session.newModelMapperStub('MyArrayType'); | |
var obj = myArrayTypeMapper.newModelStub(uid); | |
obj.doIt(session, 'param_data', { | |
success : function(reuslt) { | |
if (result.async) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prepares an update operation. | |
var mySingletonTypeMapper = | |
session.newModelMapperStub('MySingletonType'); | |
// Creates or retrieves a model object | |
var obj = ...; | |
obj.myProperty = 'myValue'; | |
obj.myIntProperty = 12345; | |
obj.myBooleanProperty = true; | |
OlderNewer