Page 1 of 2

Update Users table collection PUT

Posted: Fri Feb 06, 2015 10:44 pm
by Illya Stepanov

Hi Hawk -

Could you please show us the network tab in your browser DevTools, what is shown there?


Update Users table collection PUT

Posted: Mon Feb 09, 2015 3:02 am
by Hawk

Hi Illya,

I'm using some development tool to send the request from Oracle DB to Appery DB. I'm not using a browser. The message above is the response I got back from Appery DB.

How can I test it in the browser? I cannot create UPDATE service on Users collection in Appery.

I tried FireFox as follows:

Many thank, Image

Image

Many thanks,


Update Users table collection PUT

Posted: Tue Feb 10, 2015 2:14 am
by Yurii Orishchuk

Hi Hawk,

Multiple update for users not allowed.

You need to use update user REST.

precode

curl -X PUT
-H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9"
-H "X-Appery-Session-Token: c6771e2f-44ae-42ea-9946-5fa320578233"
-d "{"email":"stacy@somemail.com"}"
https://api.appery.io/rest/1/db/users/54539efee4b05c4ac3b9737f

/code/pre

See details here: http://devcenter.appery.io/documentat...

Regards.


Update Users table collection PUT

Posted: Tue Feb 10, 2015 2:33 am
by Hawk

Hi Yurii,

In my last attempt, I used the following:
precontent := '{"username":"star1234","password":"star1234"}';
url:= 'https://api.appery.io/rest/1/db/users'||A_id ; /pre

Where I concatenate A_id (which is the variable contains one user _id) to the URL. So the real value is something like this:

pre 'https://api.appery.io/rest/1/db/users54539efee4b05c4ac3b9737f'/pre

So I guess I'm updating only one user. right?

In addition, I used the content:
precontent := '{"username":"star1234","password":"star1234"}';/pre

and
precontent := '{"operations":{"$set": "username":"star1234","password":"star1234"}}';/pre

and
precontent := '{"password": { "$set": "star1234"}}';/pre

And all gave me the same error in the response!


Update Users table collection PUT

Posted: Wed Feb 11, 2015 2:28 am
by Yurii Orishchuk

Hi Hawk,

Your code:

pre

url:= 'https://api.appery.io/rest/1/db/users'||A_id ;

/pre

Is not correct cause of there is not "/" between "users" and "userId".

Please use this one:

pre

url:= 'https://api.appery.io/rest/1/db/users/'||A_id ;

/pre

Regards.


Update Users table collection PUT

Posted: Wed Feb 11, 2015 4:21 am
by Hawk

Many thanks Yurii !


Update Users table collection PUT

Posted: Thu Feb 12, 2015 4:37 am
by Hawk

Hi Yurii,

I'm trying to update users passwords from Oracle DB. I need to use one user here to retrieve session-Token. But the problem is, this user is only allowed to update its own password. And when I use the session-Token with other users, I receive the response : does not have write permission to this object

I understand it's because of ACL value. When I add the user I'm using to that object, I can then update the password. But I need to write permission to this user for all objects (I have 2000 users), so I cannot go to acl field for each of them and update them one by one.

Is there any easier way to grant one user (e.g. admin) write permission over all users (update their ACL)?

Thanks,


Update Users table collection PUT

Posted: Fri Feb 13, 2015 2:09 am
by Yurii Orishchuk

Hi Hawk,

For this case you can use Master key it will allow you access objects without session token.

Please read more about it here: http://devcenter.appery.io/documentat...

Note: master-key is very sensitive information. So it's better to use it in Server code to avoid access this information to other users.

Regards.


Update Users table collection PUT

Posted: Tue Mar 03, 2015 7:24 am
by Hawk

Thanks Yurii,
Can I use Master key to delete entire collection from Oracle without using _id's values?
In fact deleting the collection object by object is taking major time for a collection of 10,000 objects.

Thanks,


Update Users table collection PUT

Posted: Wed Mar 04, 2015 2:45 am
by Yurii Orishchuk

Hi Hawk,

Unfortunatly, currently there is not such api in Appery DB.

But here is a solution to improve this processing speed:

  1. Create Server script.

  2. Populate it with following JS code:

    pre

    var dbId = "52fd3d06e4b0a25c11cxxx17";
    var collectionName = "tempCollection";
    var query = [] ;

    try
    {

    var params = {};

    params.criteria =
    {
    //here you can add query paremeters.
    };

    queryResult = Collection.query(dbId, collectionName, params);

    for(var i = 0; i < queryResult&#46;length; i++){
    Collection&#46;deleteObject(dbId, collectionName, queryResult&#46;_id);
    queryResult
    };

    response&#46;success({message: (queryResult&#46;length + " items deleted")});
    }
    catch (e)
    {
    response&#46;success("message: " + e&#46;message + "ncode: " + e&#46;code);
    }

    /pre

  3. Also you specify in this screen needed search criteria to delete items.

    Regards.