[SERVER-1069] Enforcing unique values within a document Created: 30/Apr/10  Updated: 03/May/10  Resolved: 03/May/10

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

Type: Question Priority: Minor - P4
Reporter: Kyle Banker Assignee: Eliot Horowitz (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Should it be possible to enforce uniqueness of an object within an array within a single document using a unique index?

For instance:

db.foo.save( { a : [

{ b : 1 }

] } )
db.foo.ensureIndex({_id: 1, 'a.b': 1},

{unique: true}

);

// This succeeds. Should it fail?
db.foo.update({}, { '$push' : { 'a':

{b: 1}

} });



 Comments   
Comment by Eliot Horowitz (Inactive) [ 03/May/10 ]

See SERVER-1068

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