Announcement Announcement Module
Collapse
No announcement yet.
MongoOperations' update with update modifier ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MongoOperations' update with update modifier ?

    Hello !

    This is an edited version, since yesterday's version is my tired-state-of-mind version which is kinda hard to read

    1.0.0.M5 here

    Is it possible that i use the update() builder method without actually setting anything ? In the current version, it seems that the update method must at least receive 2 params, which is the key and the value to be set.
    There are some cases where i want to just increment a field, without actually setting anything.

    The code that im currently doing to have my increment, where i have to 'fake' the set value update using update("text", "XXXXXXXXXXXX")
    Code:
    this.ops.updateFirst(
    			query(where("_id").is(id)),
    			update("text", "XXXXXXXXXXXX").inc("test", 10),
    			collectionName);
    I wonder whether this below is possible, but what i have in mind is that i dont have to set anything to do my increment, such as this code snipped (that obviously doesnt compile, since there's no update() method that is parameterless):
    Code:
    this.ops.updateFirst(
    			query(where("_id").is(id)),
    			update().inc("test", 10),
    			collectionName);
    Thanks !
    Last edited by albert_kam; Dec 1st, 2011, 10:00 PM.

  • #2
    Im sorry if replying after updating the original post is frowned upon here. But i want to dare myself, since the last question is totally hard to read.

    Thanks !

    Comment


    • #3
      I feel stupid now. Using new Update() works just fine without having to do static Update.update(key, value)

      Thank you!

      Comment

      Working...
      X