[SERVER-1911] $inc should support documents Created: 08/Oct/10  Updated: 12/Oct/10  Resolved: 08/Oct/10

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 1.7.1
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Torsten Curdt Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

If you have nested counters in a document you have always specify the full path to update them.

update(

{id:1}

, {
'some.path.into1' : 1,
'some.path.into2' : 1,
})

this quickly becomes quite verbose. Using a document for this would feel natural.

update(

{id:1}

, { '$inc': { 'some' : { 'path' :

{ 'into1' : 1, 'into2' : 1, }}

}})

the increment would be on all leaf nodes that are of type int



 Comments   
Comment by Torsten Curdt [ 12/Oct/10 ]

I didn't want to imply they have the same meaning. I know that.

All I am saying is that <how to modify> being an object for $inc is not inconsistent. You just need to define the meaning of it.

Comment by Eliot Horowitz (Inactive) [ 11/Oct/10 ]

The doc has a very different meaning.
You should make sure to read the modifier page carefully.

basically,
$set : { a :

{ b : 1 }

}
replaces the a object with

{ b : 1 }

if it was { a :

{ b : 1 , c : 1 }

} the c goes away

$set

{ "a.b" : 1 }

just changes the b

so generally

$<name> :

{ <what to modify> : <how to modify> }

so <how to moidfy> should not be an object with $inc

Comment by Torsten Curdt [ 11/Oct/10 ]

$set is not $inc ... and I am not even sure this really is inconsistent. Or for that matter - is consistent like it is right now.

Right now a document is supported as argument on $set but not on $inc. I would like to see a doc be supported there, too.
The only thing that needs to be defined is what it means to add a document.
I would think it's rather straight forward what the following would do:

$inc :

{ "a.b.c.d.e" : 1 }

$inc : { "a.b.c" : { d:

{ e: 1 }

}
$inc : { a : { b: { c: { d:

{ e: 1 }

}

and it would bring it in line with the $set operator

$set :

{ "a.b.c.d.e" : 1 }

$set : { "a.b.c" : { d:

{ e: 1 }

}
$set : { a : { b: { c: { d:

{ e: 1 }

}

Comment by Eliot Horowitz (Inactive) [ 11/Oct/10 ]

think about $set as well.
$set :

{ "a.b.c" : 1 }

is very different than
$set : { a : { b :

{ c : 1 }

} }

and we want consistency

Comment by Torsten Curdt [ 11/Oct/10 ]

Not sure I really see a problem. It's actually a document describing how to inc/dec/alter the document in place. This is "inc", not "find".

Comment by Eliot Horowitz (Inactive) [ 08/Oct/10 ]

in queries for example

{ x :

{ a : 5 }

} = find a document such that x is a document that is exactly

{a:5} { "x.a" : 5 }

= find a document such that x is a document that has a field a that is 5

Comment by Torsten Curdt [ 08/Oct/10 ]

Could you please elaborate as I don't see the semantical problem here.

Comment by Eliot Horowitz (Inactive) [ 08/Oct/10 ]

This doesn't work semantically in the query language because documents and dottted fields mean very different things.

Generated at Thu Feb 08 02:58:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.