Created
March 10, 2016 05:06
-
-
Save rakhimoni/a752797f5e88836eccd8 to your computer and use it in GitHub Desktop.
ArrowDb csutom object query using limit
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
| (function(){ | |
| var ACS = require('ti.cloud'), | |
| env = Ti.App.deployType.toLowerCase() === 'production' ? 'production' : 'development', | |
| username = Ti.App.Properties.getString('acs-username-'+env), | |
| password = Ti.App.Properties.getString('acs-password-'+env); | |
| // if not configured, just return | |
| if (!env || !username || !password) { return; } | |
| /** | |
| * Appcelerator Cloud (ACS) Admin User Login Logic | |
| * | |
| * fires login.success with the user as argument on success | |
| * fires login.failed with the result as argument on error | |
| */ | |
| ACS.Users.login({ | |
| login:username, | |
| password:password, | |
| }, function(result){ | |
| if (env==='development') { | |
| Ti.API.info('ACS Login Results for environment `'+env+'`:'); | |
| Ti.API.info(result); | |
| } | |
| if (result && result.success && result.users && result.users.length){ | |
| Ti.App.fireEvent('login.success',result.users[0],env); | |
| ACS.Objects.query({ | |
| classname: 'car123', | |
| limit:50 | |
| }, function (e) { | |
| if (e.success) { | |
| alert('Success:\n' + | |
| 'Count: ' + e.car123.length); | |
| Ti.API.info('Success:\n' + | |
| 'Count: ' + e.car123.length); | |
| for (var i = 0; i < e.car123.length; i++) { | |
| var car123 = e.car123[i]; | |
| Ti.API.info('id: ' + car123.id + '\n' + | |
| 'make: ' + car123.make + '\n' + | |
| 'color: ' + car123.color + '\n' + | |
| 'year: ' + car123.year + '\n' + | |
| 'created_at: ' + car123.created_at); | |
| } | |
| } else { | |
| alert('Error:\n' + | |
| ((e.error && e.message) || JSON.stringify(e))); | |
| } | |
| }); | |
| } else { | |
| Ti.App.fireEvent('login.failed',result,env); | |
| } | |
| }); | |
| })(); | |
| //Console logs: | |
| [INFO] : Success: | |
| [INFO] : Count: 12 | |
| [INFO] : id: 56e0face550a68090a524cde | |
| [INFO] : make: tata | |
| [INFO] : color: blue | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-03-10T04:40:46+0000 | |
| [INFO] : id: 56e0fab08d7af309083b984f | |
| [INFO] : make: kkkk | |
| [INFO] : color: blue | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-03-10T04:40:16+0000 | |
| [INFO] : id: 56e0faa053586409123c73b0 | |
| [INFO] : make: eerr | |
| [INFO] : color: blue | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-03-10T04:40:00+0000 | |
| [INFO] : id: 56e0fa8dd1f2370908bd4f04 | |
| [INFO] : make: yoyota | |
| [INFO] : color: blue | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-03-10T04:39:41+0000 | |
| [INFO] : id: 56e0fa7a8d7af309083b983a | |
| [INFO] : make: weqwedqweqweqweq | |
| [INFO] : color: red | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-03-10T04:39:22+0000 | |
| [INFO] : id: 56e0fa5fa778ca090853878e | |
| [INFO] : make: scqwhgfsqghws | |
| [INFO] : color: blue | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-03-10T04:38:55+0000 | |
| [INFO] : id: 56e0fa4cd1f2370910bc6fcb | |
| [INFO] : make: sdadasdissan | |
| [INFO] : color: blue | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-03-10T04:38:36+0000 | |
| [INFO] : id: 56e0fa3853586409123c736b | |
| [INFO] : make: wswqs | |
| [INFO] : color: blue | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-03-10T04:38:16+0000 | |
| [INFO] : id: 56e0fa2640a96d090d931018 | |
| [INFO] : make: abcd | |
| [INFO] : color: blue | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-03-10T04:37:58+0000 | |
| [INFO] : id: 56e0fa148d7af309083b97d0 | |
| [INFO] : make: pissan | |
| [INFO] : color: blue | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-03-10T04:37:40+0000 | |
| [INFO] : id: 56cecbc821498909250017e0 | |
| [INFO] : make: nissan | |
| [INFO] : color: blue | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-02-25T09:39:20+0000 | |
| [INFO] : id: 56cecb86cd9aab0920001776 | |
| [INFO] : make: nissan | |
| [INFO] : color: blue | |
| [INFO] : year: 2005 | |
| [INFO] : created_at: 2016-02-25T09:38:14+0000 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment