Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* $in operator in arrowdb cloud event query
- Test Environment:
- Appcelerator Command-Line Interface, version 5.1.0
- Titanium SDK Version 5.1.2.GA
- Appcelerator Studio, build: 4.4.0.201511241829Mac OS X,Version = 10.10.11.
- **/
- Test code:
- // create base UI tab and root window
- //
- var win1 = Titanium.UI.createWindow({
- title:'Tab 1',
- backgroundColor:'#fff'
- });
- win1.open();
- // added during app creation. this will automatically login to
- // ACS for your application and then fire an event (see below)
- // when connected or errored. if you do not use ACS in your
- // application as a client, you should remove this block
- (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);
- ACS.Events.query({
- where : {
- "name" : {
- // "$in" :['movie','netflix']
- "$in" :['movie','netflix','']
- }
- }
- //tags : {'$in': ['movie','netflix']}
- }, function(e) {
- if (e.success) {
- Ti.API.info("Total event is "+e.events.length);
- Ti.API.info( "Total event is"+JSON.stringify(e.events) );
- } else {
- alert('Some error occurred');
- }
- });
- }
- if (result && result.success && result.users && result.users.length){
- Ti.App.fireEvent('login.success',result.users[0],env);
- } else {
- Ti.App.fireEvent('login.failed',result,env);
- }
- });
- })();
- Test results (Console logs):
- [INFO] : ACS Login Results for environment `development`:
- [INFO] : {
- [INFO] : error = 0;
- [INFO] : meta = {
- [INFO] : code = 200;
- [INFO] : "method_name" = loginUser;
- [INFO] : "session_id" = qAePTNLP9w2kXIf42GMzqledg7w;
- [INFO] : status = ok;
- [INFO] : };
- [INFO] : success = 1;
- [INFO] : users = (
- [INFO] : {
- [INFO] : admin = false;
- [INFO] : "confirmed_at" = "2015-12-10T10:30:52+0000";
- [INFO] : "created_at" = "2015-12-10T10:30:52+0000";
- [INFO] : email = "";
- [INFO] : "external_accounts" = (
- [INFO] : );
- [INFO] : "friend_counts" = {
- [INFO] : friends = 0;
- [INFO] : requests = 0;
- [INFO] : };
- [INFO] : id = 5669545c4a522f0907d824c2;
- [INFO] : role = "appc-admin";
- [INFO] : stats = {
- [INFO] : photos = {
- [INFO] : "total_count" = 0;
- [INFO] : };
- [INFO] : storage = {
- [INFO] : used = 0;
- [INFO] : };
- [INFO] : };
- [INFO] : tags = (
- [INFO] : appcelerator
- [INFO] : );
- [INFO] : "updated_at" = "2016-02-07T09:23:29+0000";
- [INFO] : username = "appc_app_user_dev";
- [INFO] : }
- [INFO] : );
- [INFO] : }
- [INFO] : Total event is 2
- [INFO] : Total event is[{"id":"56b704e73477c0090b57a620","name":"netflix","start_time":"2016-02-07T08:47:00+0000","duration":7200,"created_at":"2016-02-07T08:48:39+0000","updated_at":"2016-02-07T08:48:39+0000","ical":"DTSTART:20160207T084700Z\nDURATION:PT2H","recurring_until":"2016-02-07T08:47:00+0000","num_occurrences":1,"details":"fun","user_id":"5669545c4a522f0907d824c2"},{"id":"56b704b2bb2d99bd563456d9","name":"movie","start_time":"2016-02-07T08:46:00+0000","duration":3600,"created_at":"2016-02-07T08:47:46+0000","updated_at":"2016-02-07T08:47:46+0000","ical":"DTSTART:20160207T084600Z\nDURATION:PT1H","recurring_until":"2016-02-07T08:46:00+0000","num_occurrences":1,"details":"enjoyment","user_id":"5669545c4a522f0907d824c2"}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement