Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.31 KB | None | 0 0
  1. /* $in operator in arrowdb cloud event query
  2.  
  3. Test Environment:
  4.  
  5. Appcelerator Command-Line Interface, version 5.1.0
  6. Titanium SDK Version 5.1.2.GA
  7. Appcelerator Studio, build: 4.4.0.201511241829Mac OS X,Version = 10.10.11.
  8.  
  9. **/
  10.  
  11. Test code:
  12.  
  13.  
  14. // create base UI tab and root window
  15. //
  16. var win1 = Titanium.UI.createWindow({
  17. title:'Tab 1',
  18. backgroundColor:'#fff'
  19. });
  20.  
  21. win1.open();
  22.  
  23.  
  24. // added during app creation. this will automatically login to
  25. // ACS for your application and then fire an event (see below)
  26. // when connected or errored. if you do not use ACS in your
  27. // application as a client, you should remove this block
  28. (function(){
  29. var ACS = require('ti.cloud'),
  30. env = Ti.App.deployType.toLowerCase() === 'production' ? 'production' : 'development',
  31. username = Ti.App.Properties.getString('acs-username-'+env),
  32. password = Ti.App.Properties.getString('acs-password-'+env);
  33.  
  34. // if not configured, just return
  35. if (!env || !username || !password) { return; }
  36. /**
  37. * Appcelerator Cloud (ACS) Admin User Login Logic
  38. *
  39. * fires login.success with the user as argument on success
  40. * fires login.failed with the result as argument on error
  41. */
  42. ACS.Users.login({
  43. login:username,
  44. password:password,
  45. }, function(result){
  46. if (env==='development') {
  47. Ti.API.info('ACS Login Results for environment `'+env+'`:');
  48. Ti.API.info(result);
  49.  
  50.  
  51. ACS.Events.query({
  52. where : {
  53. "name" : {
  54. // "$in" :['movie','netflix']
  55. "$in" :['movie','netflix','']
  56. }
  57. }
  58.  
  59.  
  60. //tags : {'$in': ['movie','netflix']}
  61. }, function(e) {
  62. if (e.success) {
  63. Ti.API.info("Total event is "+e.events.length);
  64. Ti.API.info( "Total event is"+JSON.stringify(e.events) );
  65.  
  66. } else {
  67. alert('Some error occurred');
  68. }
  69. });
  70. }
  71. if (result && result.success && result.users && result.users.length){
  72. Ti.App.fireEvent('login.success',result.users[0],env);
  73. } else {
  74. Ti.App.fireEvent('login.failed',result,env);
  75. }
  76. });
  77.  
  78. })();
  79.  
  80.  
  81. Test results (Console logs):
  82.  
  83. [INFO] : ACS Login Results for environment `development`:
  84. [INFO] : {
  85. [INFO] : error = 0;
  86. [INFO] : meta = {
  87. [INFO] : code = 200;
  88. [INFO] : "method_name" = loginUser;
  89. [INFO] : "session_id" = qAePTNLP9w2kXIf42GMzqledg7w;
  90. [INFO] : status = ok;
  91. [INFO] : };
  92. [INFO] : success = 1;
  93. [INFO] : users = (
  94. [INFO] : {
  95. [INFO] : admin = false;
  96. [INFO] : "confirmed_at" = "2015-12-10T10:30:52+0000";
  97. [INFO] : "created_at" = "2015-12-10T10:30:52+0000";
  98. [INFO] : email = "";
  99. [INFO] : "external_accounts" = (
  100. [INFO] : );
  101. [INFO] : "friend_counts" = {
  102. [INFO] : friends = 0;
  103. [INFO] : requests = 0;
  104. [INFO] : };
  105. [INFO] : id = 5669545c4a522f0907d824c2;
  106. [INFO] : role = "appc-admin";
  107. [INFO] : stats = {
  108. [INFO] : photos = {
  109. [INFO] : "total_count" = 0;
  110. [INFO] : };
  111. [INFO] : storage = {
  112. [INFO] : used = 0;
  113. [INFO] : };
  114. [INFO] : };
  115. [INFO] : tags = (
  116. [INFO] : appcelerator
  117. [INFO] : );
  118. [INFO] : "updated_at" = "2016-02-07T09:23:29+0000";
  119. [INFO] : username = "appc_app_user_dev";
  120. [INFO] : }
  121. [INFO] : );
  122. [INFO] : }
  123. [INFO] : Total event is 2
  124. [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