Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add variable in number set? #27

Closed
mbarinov opened this issue Aug 1, 2012 · 2 comments
Closed

How to add variable in number set? #27

mbarinov opened this issue Aug 1, 2012 · 2 comments

Comments

@mbarinov
Copy link

mbarinov commented Aug 1, 2012

I need to store my dialogs id in dialogs column. But I don't know how to set Action: ADD for adding values to existing data in number set. By default set is PUT whitch override whole NS Need help.

My attempts

var userDialog = {
            dialogs:[Number(dialog.id)]
};
dynode.updateItem('userDialogs', 1, userDialog, {"Action":"ADD"}, function (err, res) {
      if (err) {
          console.log(err);
           return false;
      }
     console.log(res);
});

My db structure

id Number ( Hash key)
dialogs Number Set

ps Sorry for english

@ryanfitz
Copy link
Member

ryanfitz commented Aug 6, 2012

@mbarinov if you look in the readme under the updateItem section you will see an example of how to do this.

var updates = {nums: {'delete' : [5]}, age: {add: 2}};

dynode.updateItem("ExampleTable", "ItemsHashKey", updates, console.log);

That updated would add the 2 to the current number for the age attribute and remove the value 5 from the nums set.

With your example here is how you would add the dialog id into the set of dialog numbers.

var userDialog = {dialogs: {add : [Number(dialog.id)]}};

dynode.updateItem('userDialogs', 1, userDialog, function (err, res) {
  if (err) {
    console.log(err);
    return callback(err);
  }

 console.log(res);
 return callback(null, res);
});

@ryanfitz ryanfitz closed this as completed Aug 6, 2012
@mbarinov
Copy link
Author

mbarinov commented Aug 7, 2012

Great thanks, It's helps me.
ps thanks for this module)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants