-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathjavascript.html
7263 lines (6146 loc) · 291 KB
/
javascript.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<head>
<meta charset="utf-8" />
<title>CloudBoost SDK Reference</title>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="assets/css/site.css" media="screen" />
<script src="assets/js/qframe.js"></script>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/jquery.cookie.js"></script>
<script src="assets/js/waypoints.js"></script>
<script src="assets/js/shared.js"></script>
<script src="assets/js/api.js"></script>
<!-- start Mixpanel -->
<script type="text/javascript">
(function (f, b) {
if (!b.__SV) {
var a, e, i, g; window.mixpanel = b; b._i = []; b.init = function (a, e, d) {
function f(b, h) { var a = h.split("."); 2 == a.length && (b = b[a[0]], h = a[1]); b[h] = function () { b.push([h].concat(Array.prototype.slice.call(arguments, 0))) } } var c = b; "undefined" !== typeof d ? c = b[d] = [] : d = "mixpanel"; c.people = c.people || []; c.toString = function (b) { var a = "mixpanel"; "mixpanel" !== d && (a += "." + d); b || (a += " (stub)"); return a }; c.people.toString = function () { return c.toString(1) + ".people (stub)" }; i = "disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
for (g = 0; g < i.length; g++)f(c, i[g]); b._i.push([a, e, d])
}; b.__SV = 1.2; a = f.createElement("script"); a.type = "text/javascript"; a.async = !0; a.src = "undefined" !== typeof MIXPANEL_CUSTOM_LIB_URL ? MIXPANEL_CUSTOM_LIB_URL : "//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js"; e = f.getElementsByTagName("script")[0]; e.parentNode.insertBefore(a, e)
}
})(document, window.mixpanel || []);
mixpanel.init("be05a4d590e8bc9d5f2cd6b3b3ffb78b");
</script>
<!-- end Mixpanel -->
</head>
<body class="api-docs node">
<div id="background"></div>
<div id="header">
<a href="https://www.cloudboost.io">
<img src="assets/images/logoc81e.png" height="40" style="float:left;margin-top:5px" />
</a>
<div class="navigation">
<div class="signin">
<a id='signin' href="https://dashboard.cloudboost.io/accounts">
<span>Sign In</span>
</a>
</div>
<ul class="global">
<li><a href="https://docs.cloudboost.io" class="selected">Documentation</a></li>
<li><a href="https://cloudboost.io/quickstart" target="_blank">Quickstart</a></li>
<li><a href="http://stackoverflow.com/questions/ask?tags=cloudboost" target="_blank">Help & Support</a></li>
</ul>
</div>
</div>
<div id="guide">
<p class="ref-title">Overview</p>
<ul class="ref-list">
<li class="section">
<a href="#Introduction" class="parent viewing">Introduction</a>
</li>
<li class="section">
<a href="#Apps" class="parent">Apps</a>
</li>
</ul>
<p class="ref-title">Classes</p>
<ul class="ref-list">
<li class="section section-charges">
<a href="#CloudApp" class="parent">App</a>
<span class="children">
<a href="#CloudApp-init" class="parent">Initialize App</a>
</span>
</li>
<li class="section section-charges">
<a href="#CloudObject" class="parent">Object</a>
<span class="children">
<a href="#CloudObject-constructor" class="parent">Constructor</a>
<a href="#CloudObject-set" class="parent">Set</a>
<a href="#CloudObject-get" class="parent">Get</a>
<a href="#CloudObject-unset" class="parent">Unset</a>
<a href="#CloudObject-save" class="parent">Save</a>
<a href="#CloudObject-fetch" class="parent">Fetch</a>
<a href="#CloudObject-delete" class="parent">Delete</a>
<a href="#CloudObject-on" class="parent">On</a>
<a href="#CloudObject-off" class="parent">Off</a>
<a href="#CloudObject-expires" class="parent">Expires</a>
<a href="#CloudObject-relate" class="parent">Relate</a>
<a href="#CloudObject-bulkInsert" class="parent">Bulk Save</a>
<a href="#CloudObject-bulkDelete" class="parent">Bulk Delete</a>
<a href="#CloudObject-pin" class="parent">Pin</a>
<a href="#CloudObject-unPin" class="parent">UnPin</a>
<a href="#CloudObject-saveEventually" class="parent">SaveEventually</a>
<a href="#CloudObject-clearLocalStore" class="parent">ClearLocalStore</a>
<a href="#CloudObject-sync" class="parent">Sync</a>
<a href="#CloudObject-disableSync" class="parent">DisableSync</a>
<!--<a href="#CloudObject-_validateNotificationQuery" class="parent">ValidateNotificationQuery</a> -->
</span>
</li>
<li class="section section-charges"><a href="#Relationships" class="parent">Relationships</a>
<span class="children">
<a href="#Relationships-oneToOne" class="parent">One-to-One</a>
<a href="#Relationships-oneToMany" class="parent">One-to-Many</a>
<a href="#Relationships-manyToMany" class="parent">Many-to-many</a>
<a href="#Relationships-query" class="parent">Query on Relationships</a>
</span>
</li>
<li class="section section-charges"><a href="#CloudQuery" class="parent">Query</a>
<span class="children">
<a href="#CloudQuery-constructor" class="parent">Constructor</a>
<a href="#CloudQuery-all" class="parent">All</a>
<a href="#CloudQuery-any" class="parent">Any</a>
<a href="#CloudQuery-first" class="parent">First</a>
<a href="#CloudQuery-search" class="parent">Search</a>
<a href="#CloudQuery-equalTo" class="parent">Equal To</a>
<a href="#CloudQuery-notEqualTo" class="parent">Not Equal To</a>
<a href="#CloudQuery-delete" class="parent">Delete</a>
<a href="#CloudQuery-containedIn" class="parent">Contained In</a>
<a href="#CloudQuery-containsAll" class="parent">Contains All</a>
<a href="#CloudQuery-notContainedIn" class="parent">Not Contained In</a>
<a href="#CloudQuery-greaterThan" class="parent">Greater Than</a>
<a href="#CloudQuery-greaterThanEqualTo" class="parent">Greater Than and Equal To</a>
<a href="#CloudQuery-lessThan" class="parent">Less Than</a>
<a href="#CloudQuery-lessThanEqualTo" class="parent">Less than and equal to</a>
<a href="#CloudQuery-startsWith" class="parent">Starts With</a>
<a href="#CloudQuery-or" class="parent">Or</a>
<a href="#CloudQuery-orderByAsc" class="parent">Ascending Order</a>
<a href="#CloudQuery-orderByDesc" class="parent">Decending Order</a>
<a href="#CloudQuery-setLimit" class="parent">Limit</a>
<a href="#CloudQuery-setSkip" class="parent">Skip</a>
<a href="#CloudQuery-paginate" class="parent">Paginate</a>
<a href="#CloudQuery-selectColumn" class="parent">Select Column</a>
<a href="#CloudQuery-doNotSelectColumn" class="parent">Do Not Select Column</a>
<a href="#CloudQuery-exists" class="parent">Exists</a>
<a href="#CloudQuery-doesNotExists" class="parent">Does not exist</a>
<a href="#CloudQuery-find" class="parent">Find</a>
<a href="#CloudQuery-findOne" class="parent">Find One</a>
<a href="#CloudQuery-findFromLocalStore" class="parent">Find From Local Store</a>
<a href="#CloudQuery-findById" class="parent">Find By Id</a>
<a href="#CloudQuery-get" class="parent">Get</a>
<a href="#CloudQuery-count" class="parent">Count</a>
<a href="#CloudQuery-distinct" class="parent">Distinct</a>
<a href="#CloudQuery-include" class="parent">Include</a>
<a href="#CloudQuery-near" class="parent">Near</a>
<a href="#CloudQuery-geowithin" class="parent">GeoWithin</a>
<a href="#CloudQuery-regex" class="parent">Regex</a>
<a href="#CloudQuery-substring" class="parent">Substring</a>
<!--<a href="#CloudQuery-_validateQuery" class="parent">Validate Query</a> -->
</span>
</li>
<li class="section section-charges"><a href="#CloudNotifcations" class="parent">Notifications</a>
<span class="children">
<a href="#CloudNotification-on" class="parent">Subscribe</a>
<a href="#CloudNotification-publish" class="parent">Publish</a>
<a href="#CloudNotification-off" class="parent">Unsubscribe</a>
</span>
</li>
<li class="section section-charges">
<a href="#CloudPushNotifcations" class="parent">PushNotifications</a>
<span class="children">
<a href="#CloudPushNotifcations-send" class="parent">Send</a>
<a href="#CloudPushNotifcations-enableWebNotifications" class="parent">Enable Web Notifications</a>
<a href="#CloudPushNotifcations-disableWebNotifications" class="parent">Disable Web Notifications</a>
<a href="#CloudPushNotifcations-_addDevice" class="parent">Add Device</a>
<a href="#CloudPushNotifcations-_deleteDevice" class="parent">Delete Device</a>
</span>
</li>
<li class="section section-charges"><a href="#CloudGeoPoint" class="parent">GeoPoint</a>
<span class="children">
<a href="#CloudGeoPoint-constructor" class="parent">Constructor</a>
<a href="#CloudGeoPoint-dkm" class="parent">Distance In kilometers</a>
<a href="#CloudGeoPoint-miles" class="parent">Distance In Miles</a>
<a href="#CloudGeoPoint-radians" class="parent">Distance In Radians</a>
</span>
</li>
<li class="section section-charges"><a href="#CloudUser" class="parent">User</a>
<span class="children">
<a href="#CloudUser-signUp" class="parent">Signup</a>
<a href="#CloudUser-logIn" class="parent">Login</a>
<a href="#CloudUser-logOut" class="parent">Logout</a>
<a href="#CloudUser-getCurrentUser" class="parent">Get Current User</a>
<a href="#CloudUser-_getCurrentUser" class="parent">_Get Current User</a>
<a href="#CloudUser-current" class="parent">Current</a>
<a href="#CloudUser-_setCurrentUser" class="parent">Set Current User</a>
<a href="#CloudUser-_removeCurrentUser" class="parent">Remove Current User</a>
<a href="#CloudUser-authenticateWithProvider" class="parent">Authenticate Provider</a>
<a href="#CloudUser-addToRole" class="parent">Add To Role</a>
<a href="#CloudUser-isInRole" class="parent">Is In Role</a>
<a href="#CloudUser-removeFromRole" class="parent">Remove from Role</a>
<a href="#CloudUser-changePassword" class="parent">Change Password</a>
<a href="#CloudUser-resetPassword" class="parent">Reset Password</a>
</span>
</li>
<li class="section section-charges"><a href="#CloudRole" class="parent">Role</a>
<span class="children">
<a href="#CloudRole-constructor" class="parent">Constructor</a>
</span>
</li>
<li class="section section-charges"><a href="#CloudFile" class="parent">File</a>
<span class="children">
<a href="#CloudFile-constructor" class="parent">Constructor</a>
<a href="#CloudFile-save" class="parent">Save</a>
<a href="#CloudFile-delete" class="parent">Delete</a>
<a href="#CloudFile-fetch" class="parent">Fetch</a>
<a href="#CloudFile-getFileContent" class="parent">GetFileContent</a>
</span>
</li>
<li class="section section-charges">
<a href="#CloudCache" class="parent">Cache</a>
<span class="children">
<a href="#CloudCache-set" class="parent">Set</a>
<a href="#CloudCache-deleteItem" class="parent">Delete Items</a>
<a href="#CloudCache-create" class="parent">Create</a>
<a href="#CloudCache-get" class="parent">Get</a>
<a href="#CloudCache-getInfo" class="parent">Get info</a>
<a href="#CloudCache-getItemsCount" class="parent">Get Items Count</a>
<a href="#CloudCache-getAll" class="parent">Get All</a>
<a href="#CloudCache-clear" class="parent">Clear</a>
<a href="#CloudCache-delete" class="parent">Delete</a>
<a href="#CloudCache-deleteAll" class="parent">Delete All</a>
</span>
</li>
<li class="section section-charges">
<a href="#CloudQueue" class="parent">Queue</a>
<span class="children">
<a href="#CloudQueue-addMessage" class="parent">Add Message</a>
<a href="#CloudQueue-updateMessage" class="parent">Update Message</a>
<a href="#CloudQueue-getMessage" class="parent">Get Message</a>
<a href="#CloudQueue-getAllMessages" class="parent">Get All Messages</a>
<a href="#CloudQueue-getMessageById" class="parent">Get Message</a>
<a href="#CloudQueue-get" class="parent">Get</a>
<a href="#CloudQueue-create" class="parent">Create</a>
<a href="#CloudQueue-addSubscriber" class="parent">Add Subscriber</a>
<a href="#CloudQueue-removeSubscriber" class="parent">Remove Subscriber</a>
<a href="#CloudQueue-peekMessage" class="parent">Peek Message</a>
<a href="#CloudQueue-delete" class="parent">Delete</a>
<a href="#CloudQueue-deleteMessage" class="parent">Delete Message</a>
<a href="#CloudQueue-clear" class="parent">Clear</a>
<a href="#CloudQueue-refreshMessageTimeout" class="parent">Refresh Message</a>
<a href="#CloudQueue-update" class="parent">Update</a>
<!--<a href="#CloudQueue-getAll" class="parent">Delete Device</a> -->
<a href="#CloudQueue-QueueMessage" class="parent">Queue Message</a>
</span>
</li>
<li class="section section-charges">
<a href="#Column" class="parent">Column</a>
<span class="children">
<a href="#Column-constructor" class="parent">Constructor</a>
<a href="#Column-datatype" class="parent">Data Type</a>
<a href="#Column-required" class="parent">Required</a>
<a href="#Column-unique" class="parent">Unique</a>
</span>
</li>
<li class="section section-charges">
<a href="#CloudTable" class="parent">Table</a>
<span class="children">
<a href="#CloudTable-constructor" class="parent">Constructor</a>
<a href="#CloudTable-get" class="parent">Get</a>
<a href="#CloudTable-getall" class="parent">GetAll</a>
<a href="#CloudTable-addcolumn" class="parent">Add Column</a>
<a href="#CloudTable-deletecolumn" class="parent">Delete Column</a>
<a href="#CloudTable-save" class="parent">Save</a>
<a href="#CloudTable-delete" class="parent">Delete</a>
<a href="#CloudTable-getColumn" class="parent">Get Column</a>
<a href="#CloudTable-updateColumn" class="parent">Update Column</a>
</span>
</li>
<li class="section section-charges"><a href="#ACL" class="parent">Access Control List (ACL)</a>
<span class="children">
<a href="#ACL-constructor" class="parent">Constructor</a>
<a href="#ACL-setPublicWriteAccess" class="parent">Public Write Access</a>
<a href="#ACL-setPublicReadAccess" class="parent">Public Read Access</a>
<a href="#ACL-setUserWriteAccess" class="parent">User Write Access</a>
<a href="#ACL-setUserReadAccess" class="parent">User Read Access</a>
<a href="#ACL-setRoleWriteAccess" class="parent">Role Write Access</a>
<a href="#ACL-setRoleReadAccess" class="parent">Role Read Access</a>
</span>
</li>
<li class="section section-charges"><a href="#JSON" class="parent">JSON</a>
<span class="children">
<a href="#JSON-serialize" class="parent">Serialize to JSON</a>
<a href="#JSON-deserialize" class="parent">Deserialize from JSON</a>
</span>
</li>
<li class="section section-charges"><a href="#Contribute" class="parent">Contribute</a>
</li>
</ul>
</div>
<!-- api docs -->
<div id="api-docs">
<a id="top" name="top" class="section-anchor"> </a>
<div id="methods">
<div class="border"></div>
<div id="language">
<a id="javascript-sdk" class="language" href="javascript.html">JavaScript</a>
</div>
<div class="method">
<a id='Introduction' name="Introduction" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h1>API Reference</h1>
<p>
The CloudBoost API is organized around <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a>.
Our API is designed to have predictable, resource-oriented URLs and to use HTTP response codes to indicate
API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which can be understood
by off-the-shelf HTTP clients, and we support <a href="http://en.wikipedia.org/wiki/Cross-origin_resource_sharing">cross-origin resource sharing</a> to allow you to interact securely with our API from a client-side web application/mobile application (though
you should remember that you should never expose your secret API master key in any public website's client-side
code, Client Key can be exposed).
<a href="http://www.json.org/">JSON</a> will be returned in all responses from the API, including errors (though
if you're using API bindings/SDK, we will convert the response to the appropriate language-specific object).
</p>
</div>
<div class="method-example" id="api-summary-example">
<h3>JavaScript SDK</h3>
<h4>Non-minified :</h4> <a href="https://cloudboost.io/js-sdk/cloudboost.js" target="_blank">
<code>https://cloudboost.io/js-sdk/cloudboost.js</code>
</a> <br/>
<h4>Minified JS :</h4> <a href="https://cloudboost.io/js-sdk/cloudboost.min.js" target="_blank">
<code>https://cloudboost.io/js-sdk/cloudboost.min.js</code>
</a><br/>
<h4>NPM :</h4>
<code>npm install <b>cloudboost</b></code>
<code>var CB = require('cloudboost');</code>
<br/>
<h4>GitHub :</h4> <a href="https://github.com/CloudBoost/JavaScriptSDK/">
<code>https://github.com/CloudBoost/JavaScriptSDK</code>
</a><br/>
</div>
</div>
</div>
<div class="method">
<a id='Apps' name="Apps" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h1>Apps</h1>
<p>
In Cloudboost, you create an app each of which has its own AppID, Client Key and the Master Key that you apply to your web
app. Your master key is a secret which should not be shared in your client apps. Your account on CloudBoost
can accommodate multiple apps. This is useful even if you have one application since you can deploy different
versions for test and production.
</p>
</div>
<div class="method-example" id="api-summary-example">
</div>
</div>
</div>
<div class="method">
<a id='CloudApp' name="CloudApp" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h1>CB.CloudApp</h1>
<!--<p>
This Class helps you to Initialize Application with CloudBoost, with the following method :-
</p>-->
</div>
<div class="method-example" id="api-summary-example">
</div>
</div>
<a id='CloudApp-init' name="CloudApp-init" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CloudApp.init( <code>appId, appKey</code> )</h3>
<p>
Initialize's the Application with CloudBoost
</p>
<p>
For each Application you create, there are two keys provided by CloudBoost,
<ol>
<li><b>#1 - Client Key </b></li>
<li><b>#2 - Master Key </b></li>
</ol>
<br/> If you want a client of your app to have access to CloudBoost API, then its <b>recommended to initiate your app with your respective <i>ClientKey</i> only.</b>
<br/><br/>
<b>We don't recommend you to initiate your app with <i>MasterKey</i> unless you install our API and make requests from your own server.</b>
</p>
<div class="method-list">
<h6>Arguments</h6>
<dl class="argument-list">
<dt>appId</dt>
<dd class="">Application ID <span>with which your app is registered. You can find this on your CloudBoost Dashboard</span></dd>
<div class="clearfix"></div>
<dt>appKey</dt>
<dd class="">Client / Master key <span>Secret Key for your app. You can find this on your CloudBoost Dashboard</span></dd>
<div class="clearfix"></div>
</dl>
<h6>Returns</h6>
<p>void</p>
</div>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node"><span class="highlight_js javascript">
CB.CloudApp.init('YOUR APP ID', 'YOUR APP KEY');
</span></span></code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
</div>
<!-- method -->
<div class="method">
<a id='CloudObject' name="CloudObject" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h1>CB.CloudObject</h1>
<p>
This class represents data in CloudBoost. <br/><br/> Each instance of <code>CB.CloudObject</code> represents
a row of table in Database. The data stored in CloudObject has schema which you can define in Table Designer
in CloudBoost portal. CloudBoost is schema-mix, so you can store or validate the piece of data with a schema.
<br/>
<br/>It allows you to store data in key-value pairs, in database designed by you.
</p>
</div>
<div class="method-example" id="api-summary-example">
</div>
</div>
<a id='CloudObject-constructor' name="CloudObject-constructor" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>Constructor : CloudObject( <code>columnName, [objectId]</code> )</h3>
<p>
Instantiates a <code>CloudObject</code> object.
</p>
<div class="method-list">
<h6>Argument</h6>
<dl class="argument-list">
<dt>tableName</dt>
<dd class="">string <span>The name of the table in database</span></dd>
<div class="clearfix"></div>
<dt>objectId</dt>
<dd class="">[optional] string <span>The ID of the Object <br/><b>Important : Use this parameter only when you're working on relations.</b></span></dd>
<div class="clearfix"></div>
</dl>
<h6>Returns</h6>
<p>It returns an instance of a CloudObject, as its a constructor. </p>
</div>
<div class="method-list">
<h6>Properties</h6>
<p>Every instance of CloudObject has these properties </p>
<dl class="argument-list">
<dt>id</dt>
<dd class="">string <span>The id of the CloudObject which is populated after the object is saved.</span></dd>
<div class="clearfix"></div>
<dt>createdAt</dt>
<dd class="">Date <span>The Date and time when the object was saved in the database.</span></dd>
<div class="clearfix"></div>
<dt>updatedAt</dt>
<dd class="">Date <span>The Date and time when the object was updated in the database.</span></dd>
<div class="clearfix"></div>
<dt>ACL</dt>
<dd class="">ACL <span>Access Control List, by default this object is publicily readable and writeable. You set object level security here. Refer <a href="/#ACL">ACL's</a></span></dd>
<div class="clearfix"></div>
</dl>
</div>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node">
<span class="highlight_js javascript">
//creates an object for Student table
var obj = new CB.CloudObject("Student");
</span></span></code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
<a id='CloudObject-set' name="CloudObject-set" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CloudObject.set( <code>columnName, data</code> )</h3>
<p>
Sets the value of an attribute of an instance of a <code>CloudObject</code>.
</p>
<div class="method-list">
<h6>Arguments</h6>
<dl class="argument-list">
<dt>columnName</dt>
<dd class="">string <span>The name of the column whose value is to be set.</span></dd>
<div class="clearfix"></div>
<dt>data</dt>
<dd class="">Any data<span>The value which is to be stored in the column.</span></dd>
<div class="clearfix"></div>
</dl>
<h6>Returns</h6>
<p>void</p>
</div>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node"><span class="highlight_js javascript">
var obj = new CB.CloudObject('Student'); //create a new object.
obj.set("name", "John Smith"); //store string
obj.set("age", 21); // store number
obj.set("address", {
city: "Hyderabad",
state: "Telangana",
country: "India"
}); // store in object
</span></span></span></code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
<a id='CloudObject-get' name="CloudObject-get" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CloudObject.get( <code>columnName</code> )</h3>
<p>
Gets the value of a column of an instance of <code>CloudObject</code>.
</p>
<div class="method-list">
<h6>Argument</h6>
<dl class="argument-list">
<dt>columnName</dt>
<dd class="">string <span>The name of the column whose value is to be fetched.</span></dd>
<div class="clearfix"></div>
</dl>
<h6>Returns</h6>
<p>It returns the value of column which was previously set otherwise returns <code>undefined</code> if the column
is not set to a value.</p>
</div>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node"><span class="highlight_js javascript">
var address = obj.get('address'); //get the data.
/* address will be
{
city: "Hyderabad",
state: "Telangana",
country: "India"
}
which was saved in the object using object.set
*/
</span></span></span></code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
<a id='CloudObject-unset' name="CloudObject-unset" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CloudObject.unset( <code>columnName</code> )</h3>
<p>
Removes the value of a column of an instance of a <code>CloudObject</code> to <code>null</code>.
</p>
<div class="method-list">
<h6>Argument</h6>
<dl class="argument-list">
<dt>columnName</dt>
<dd class="">string <span>The name of the column which is to be unset.</span></dd>
<div class="clearfix"></div>
</dl>
<h6>Returns</h6>
<p>void</p>
</div>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node"><span class="highlight_js javascript">
var obj = new CB.CloudObject('Student');
obj.set("name", "John Smith");
obj.get("name"); //returns John Smith.
obj.unset("name");
obj.get("name"); //returns null.
</span></span></code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
<a id='CloudObject-save' name="CloudObject-save" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CloudObject.save( <code>[callback]</code> )</h3>
<p>
Saves the instance of <code>CloudObject</code> to CloudBoost.
</p>
<div class="method-list">
<h6>Argument</h6>
<dl class="argument-list">
<dt>callback</dt>
<dd class="">Object <span> [optional] if provided must have success and error functions to handle
respective response.</span></dd>
<div class="clearfix"></div>
</dl>
<h6>Returns</h6>
<p>It returns a <code>Promise</code> which when resolved and returns instance of <code>CloudObject </code> saved
.If the promise is rejected, you get an error object back. (if <code>callback</code> is not provided).</p>
</div>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node"><span class="highlight_js javascript">
var obj = new CB.CloudObject('Student');
obj.set("name", "Smith");
obj.save({
success: function(obj) {
//Saving successfull
//obj is instance of CloudObject
},
error: function(err) {
//Error occured in saving the object
}
});
</span></span></span></code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
<a id='CloudObject-fetch' name="CloudObject-fetch" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CloudObject.fetch( <code>[callback]</code> )</h3>
<p>
Refreshes a <code>CloudObject</code> object by fetching its values from the database.
</p>
<div class="method-list">
<h6>Argument</h6>
<dl class="argument-list">
<dt>callback</dt>
<dd class="">Object <span> [optional] if provided must have success and error functions to handle respective response.</span></dd>
<div class="clearfix"></div>
</dl>
<h6>Returns</h6>
<p>It returns <code>Promise</code> whcih resolves or rejects (if <code>callback</code> is not provided).</p>
</div>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node"><span class="highlight_js javascript">
obj.fetch({
success: function(obj) {
//obj is an instance of a refreshed CloudObject
},
error: function(err) {
//Error occurred in fetching the data
}
});
</span></span></span></code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
<a id='CloudObject-delete' name="CloudObject-delete" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CloudObject.delete( <code>[callback]</code> )</h3>
<p>
Delete a <code>CloudObject</code> object, if it is saved in the database.
</p>
<div class="method-list">
<h6>Argument</h6>
<dl class="argument-list">
<dt>callback</dt>
<dd class="">Object <span> [optional] if provided must have success and error functions to handle
respective response.</span></dd>
<div class="clearfix"></div>
</dl>
<h6>Returns</h6>
<p>It returns <code>Promise</code> which resolves or rejects (if <code>callback</code> is not provided).</p>
</div>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node"><span class="highlight_js javascript">
obj.delete({
success: function(obj) {
//success
},
error: function(err) {
//Error
}
});
</span></span></code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
<a id='CloudObject-on' name="CloudObject-on" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CloudObject.on( <code> tableName, eventType, functionToFire, [callback] </code>)</h3>
<p>
Realtime Notifications : Listens to <code>CloudObject</code> events like insert, update, delete in the database.
</p>
<div class="method-list">
<h6>Argument</h6>
<dl class="argument-list">
<dt>tableName</dt>
<dd class="">String <span> Name of the table on which you want to listen for events.
respective response.</span></dd>
<div class="clearfix"></div>
<dt>eventType</dt>
<dd class="">String / Array<span> Type of an event you want to listen to, Only <code> created, updated, deleted </code> are supported values.</span></dd>
<div class="clearfix"></div>
<dt>functionToFire</dt>
<dd class="">Function <span> Your custom function to fire when the event occours</dd>
<div class="clearfix"></div>
<dt>callback</dt>
<dd class="">Object <span> [optional] Success/Error callback if the subscribe to event was successful / failed.
<div class="clearfix"></div>
</dl>
<h6>Returns</h6>
<p>It returns a <code>Promise</code> (if <code>callback</code> is not provided).</p>
</div>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node"><span class="highlight_js javascript">
//listen to an event
CB.CloudObject.on('Student', //name of the table
'created', //type of an event
function(obj){ //your custom function which you want to fire.
//obj is an instance of CloudObject
console.log('Student Created : '+obj.get('name'));
},{ //callback
success : function(){
//subscribe success
},
error : function(err){
//failed
}
});
</span></span>
</span>
</code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
<a id='CloudObject-off' name="CloudObject-off" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CloudObject.off( <code> tableName, eventType, [callback] </code>)</h3>
<p>
Realtime Notifications : Switches off listening to <code>CloudObject</code> events like insert, update, delete
in the database.
</p>
<div class="method-list">
<h6>Argument</h6>
<dl class="argument-list">
<dt>tableName</dt>
<dd class="">String <span> Name of the table on which you want to stop listening for events to.
respective response.</span></dd>
<div class="clearfix"></div>
<dt>eventType</dt>
<dd class="">String / Array<span> Type of an event you want to stop listening to, Only <code> created, updated, deleted </code> are supported values.</span></dd>
<div class="clearfix"></div>
<dt>callback</dt>
<dd class="">Object <span> [optional] Success/Error callback if the unsubscribe to event was successful / failed.
<div class="clearfix"></div>
</dl>
<h6>Returns</h6>
<p>It returns a <code>Promise</code> (if <code>callback</code> is not provided).</p>
</div>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node"><span class="highlight_js javascript">
//stop listening to an event
CB.CloudObject.off('Student', //name of the table
'created', //type of an event
{ //callback
success : function(){
//unsubscribe success
},
error : function(err){
//unsubscribe failed
}
});
</span></span>
</span>
</code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
<a id='CloudObject-expires' name="CloudObject-expires" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CloudObject.expires</h3>
<p>
Automatically deletes the object from the database at specified time. Sets the expiration time for <code>CloudObject</code>.
Expiration time is to be given as number of milliseconds from 1 Jan 1970.
</p>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node"><span class="highlight_js javascript">
var obj = new CB.CloudObject('Student');
obj.set('name', 'John Smith');
expire=new Date().getTime()+1000; //increase the expiration time by 1 second from current time
obj.expires = expires; //Set the expire time for object Student
</span></span></span></code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
</div>
<!-- method -->
<br/><br/>
<a id='CloudObject-relate' name="CloudObject-relate" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CloudObject.relate(<code>columnName,tableName,objectId</code>)</h3>
<p>
Relates a <code>CloudObject</code> which is already saved to this <code>CloudObject</code>. Can be used to
relate objects together in a relation.
</p>
<div class="method-list">
<h6>Argument</h6>
<dl class="argument-list">
<dt>columnName</dt>
<dd class="">String <span> Name of the column of the current <code>CloudObject</code>.
</span></dd>
<div class="clearfix"></div>
<dt>tableName</dt>
<dd class="">String <span> Name of the table of the <code>CloudObject</code> which you want to relate to.
</span></dd>
<div class="clearfix"></div>
<dt>objectId</dt>
<dd class="">String <span> Id of the object which you want to relate to.
</span></dd>
<div class="clearfix"></div>
</dl>
<h6>Returns</h6>
<p>void</p>
</div>
</div>
<div class="method-example" id="api-summary-example">
<code class="method-request"><span class="prompt"></span><span class="lang lang-node"><span class="highlight_js javascript">
var obj = new CB.CloudObject('Student');
obj.relate('teacher','Teacher','xxxxxx'); //relates the teacher in the Teacher table with id xxxxx to this student.
</span></span></span></code>
</div>
<!-- method-example -->
</div>
<!-- method-section -->
<a id='CloudObject-bulkInsert' name="CloudObject-bulkInsert" class="section-anchor"> </a>
<div class="method-section">
<div class="method-description">
<h3>CB.CloudObject.saveAll(<code>ObjectArray, [callback]</code>)</h3>
<p>
Saves an Array of <code>CloudObject</code>.
</p>
<div class="method-list">
<h6>Argument</h6>
<dl class="argument-list">
<dt>ObjectArray</dt>
<dd class="">Array <span> Array of CloudObjects.
</span></dd>
<div class="clearfix"></div>
<dt>callback</dt>
<dd class="">Object <span> [optional] if provided must have success and error functions to handle
respective response.</span></dd>
</dl>
</dl>
<h6>Returns</h6>
<p>Array of Saved <code>CloudObjects</code></p>
</div>
</div>