cycle through all users in database

This forum contains topics that were moved from Get Satisfaction
Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

cycle through all users in database

Post by Jack Bua »

Speedway. Shared.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

cycle through all users in database

Post by Illya Stepanov »

And please specify the service name that you're testing?

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

cycle through all users in database

Post by Jack Bua »

get_user

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

cycle through all users in database

Post by Illya Stepanov »

Thanks, Jack. We testing it.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

cycle through all users in database

Post by Yurii Orishchuk »

Hi Jack,

You use " X-Appery-Database-Id" parameter in headers.

But correct is: "X-Appery-Database-Id"

You need to delete whitespace in the beginning on the this parameter name.

Regards.

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

cycle through all users in database

Post by Jack Bua »

That solved my problem. Thank you.

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

cycle through all users in database

Post by Terry Gilliver »

Hello, I have tried the following javascript:

pre
/* loop through users */
var users = Apperyio.storage.users.get();
var arrayLength = users.length;
var databaseId = ThePlough_settings.database_id;
console.log('database id = ',databaseId);
var sessionToken = Apperyio.storage.sessionToken.get();
console.log('session token = ', sessionToken);

for (i = 0; i < arrayLength; i++) {
console&#46;log(users&#46;userId);

Code: Select all

 /* updateUsers&#46;execute({body : {where : {user_id : users[i]&#46;userId}, operations : {$set : {events_available : true} } } }); */ 

 updateUsers&#46;execute({ 
     data: 
     { 
         "events_available" : true,  
         "where" : {"user_id" : users[i]&#46;userId} 
     }, 
     headers: 
     { 
         "X-Appery-Session-Token": sessionToken, 
         "X-Appery-Database-Id": databaseId, 
         "Content-Type": "application/json" 
     } 
 }); 

}
/pre

I am getting the following output in networking tab:

pre
GENERAL
Remote Address:54&#46;221&#46;205&#46;233:443
Request URL:https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/users/
Request Method:PUT
Status Code:405 Method Not Allowed

RESPONSE HEADERS
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http:&#47;&#47;appery&#46;io
Connection:keep-alive
Content-Type:application/json
Date:Tue, 04 Aug 2015 08:55:47 GMT
Server:nginx
Transfer-Encoding:chunked

REQUEST HEADERS
Accept:application/json, text/javascript, /; q=0&#46;01
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-GB,en-US;q=0&#46;8,en;q=0&#46;6
Connection:keep-alive
Content-Length:72
Content-Type:application/json
Host:api&#46;appery&#46;io
Origin:http:&#47;&#47;appery&#46;io
Referer:http:&#47;&#47;appery&#46;io/app/view/e1041392-556e-4f5d-93af-c73ab11d735a/EventsAdministration&#46;html
User-Agent:Mozilla/5&#46;0 (Windows NT 6&#46;3; WOW64) AppleWebKit/537&#46;36 (KHTML, like Gecko) Chrome/44&#46;0&#46;2403&#46;125 Safari/537&#46;36
X-Appery-Database-Id:55757b65e4b0c5383ba566bf
X-Appery-Session-Token:ccf1f621-79b3-4472-8b4e-b09fa6239acc

REQUEST PAYLOAD
{"events_available":true,"where":{"user_id":"55758504e4b0b40eb7813c50"}}
/pre

I have run out of ideas. I wish that the documentation had more examples. It is not very clear.

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

cycle through all users in database

Post by Terry Gilliver »

I am not really sure where I should use quotes or not

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

cycle through all users in database

Post by Terry Gilliver »

This was my last attempt:

pre/* loop through users */
var users = Apperyio&#46;storage&#46;users&#46;get();
var arrayLength = users&#46;length;
var databaseId = ThePlough_settings&#46;database_id;
console&#46;log('database id = ',databaseId);
var sessionToken = Apperyio&#46;storage&#46;sessionToken&#46;get();
console&#46;log('session token = ', sessionToken);

for (i = 0; i < arrayLength; i++) {
console&#46;log(users&#46;userId);

Code: Select all

 /* updateUsers&#46;execute({body : {where : {user_id : users[i]&#46;userId}, operations : {$set : {events_available : true} } } }); */ 

 /* updateUsers&#46;execute({ 
     data: 
     { 
         "events_available" : true,  
         "where" : {"user_id" : users[i]&#46;userId} 
     }, 
     headers: 
     { 
         "X-Appery-Session-Token": sessionToken, 
         "X-Appery-Database-Id": databaseId, 
         "Content-Type": "application/json" 
     } 
 }); */ 

 updateUsers&#46;execute({ 
     body: 
     { 
         where : {"user_id" : users[i]&#46;userId}, 
         operations : {$set : {"events_available" : true}} 
     }, 
     headers: 
     { 
         "X-Appery-Session-Token": sessionToken, 
         "X-Appery-Database-Id": databaseId, 
         "Content-Type": "application/json" 
     } 
 }); 

}/pre

output is:

Image

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

cycle through all users in database

Post by Alena Prykhodko »

Replied via regular email.

Post Reply