This file contains hidden or 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
// This script endpoint: /plugin/addcar.bb | |
var capitalize = function(str) { | |
return str.charAt(0).toUpperCase() + str.slice(1); | |
} | |
on('install',function(installEvent){ | |
Box.DB.ensureCollection("cars"); | |
return true; |
This file contains hidden or 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
// GET /plugin/geo.bb?ip=xx.yy.zz.kk | |
var endpoint="http://www.geoplugin.net/json.gp?ip="; | |
http().get(function(req){ | |
var ip=req.queryString.ip | |
if (!ip) return {status:400,content:"Missing ip parameter"}; | |
ip=ip[0]; | |
Box.log(endpoint+ip); | |
var result=Box.WS.get(endpoint,{params:{ip:ip}}); |
This file contains hidden or 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
BaasBox.fetchUserProfile("cesare") | |
.done(function(res) { | |
console.log("res ", res['data']); | |
}) | |
.fail(function(error) { | |
console.log("error ", error); | |
}) |
This file contains hidden or 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
BaasBox.fetchCurrentUser() | |
.done(function(res) { | |
console.log("res ", res['data']); | |
}) | |
.fail(function(error) { | |
console.log("error ", error); | |
}) |
This file contains hidden or 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
BaasBox.updateField("123-456", "posts", "title", "new title") | |
.done(function(res) { | |
console.log("res ", res); | |
}) | |
.fail(function(error) { | |
console.log("error ", error); | |
}) |
This file contains hidden or 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
BaasBox.loadObject("posts", "9e2921b0-cb60-4fc6-aa9b-28f4a8df4f0e") | |
.done(function(res) { | |
console.log("res ", res['data']); | |
}) | |
.fail(function(error) { | |
console.log("error ", error); | |
}) |
This file contains hidden or 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
BaasBox.loadCollectionWithParams("posts", {where: "color='red'"}) | |
.done(function(res) { | |
console.log("res ", res); | |
}) | |
.fail(function(error) { | |
console.log("error ", error); | |
}) |
This file contains hidden or 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
BaasBox.loadCollectionWithParams("posts", {page: 2, recordsPerPage: 20}) | |
.done(function(res) { | |
console.log("res ", res); | |
}) | |
.fail(function(error) { | |
console.log("error ", error); | |
}) |
This file contains hidden or 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
BaasBox.loadCollection("posts") | |
.done(function(res) { | |
console.log("res ", res); | |
}) | |
.fail(function(error) { | |
console.log("error ", error); | |
}) |
This file contains hidden or 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
BaasBox.deleteObject("123-456-789", "posts") | |
.done(function(res) { | |
console.log("res ", res); | |
}) | |
.fail(function(error) { | |
console.log("error ", error); | |
}) |