Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Tuples in Mongo document with same key?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Russell Bateman  
View profile   Translate to Translated (View Original)
 More options Aug 22 2012, 7:50 pm
From: Russell Bateman <r...@windofkeltia.com>
Date: Wed, 22 Aug 2012 17:50:23 -0600
Local: Wed, Aug 22 2012 7:50 pm
Subject: Tuples in Mongo document with same key?

Is there no way in Mongo to get a document that looks like the one I'm
trying to insert here?

     > db.subs.insert( { "x":9, "tuple":"value", "tuple":"value",
    "tuple":"different value" } );

     > db.subs.findOne();
    {
         "_id" : ObjectId("50356db633f95e308785e7d4"),
         "x" : 9,
         "tuple" : "different value"
    }

     > db.subs.insert( { "x":9, "data": { "tuple":"value",
    "tuple":"value", "tuple":"different value" } } );

     > db.subs.findOne();
    {
         "_id" : ObjectId("50356db633f95e308785e7d5"),
         "x" : 9,
         "data" : {
             "tuple" : "different value"
         }
    }

Note that the first two tuples were ignored/dropped/overwritten, and not
just because they had the same value. I'm not totally surprised by this,
but I wondered. Certainly it's the case in the Java driver, in
BasicDBObject, that stuff is done in a Map which doesn't allow multiple
identical keys so it's doubtful I could get anything back anyway.

Would someone like to growl at me or discuss this? If it worked, I could
make use of it and in fact had been blithely writing code as if it
worked until a little while later noticing that it did not.

Many thanks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kristina Chodorow  
View profile  
 More options Aug 23 2012, 10:22 am
From: Kristina Chodorow <krist...@10gen.com>
Date: Thu, 23 Aug 2012 07:22:58 -0700 (PDT)
Local: Thurs, Aug 23 2012 10:22 am
Subject: Re: Tuples in Mongo document with same key?

BSON doesn't specifically disallow it, but most languages don't support it.
 C++ and C do, but languages that implement documents as hashes can't.
 Even if you saved a doc with duplicate keys in C/C++, you wouldn't be able
to see them in the shell.  And querying for it would be kind of wacky.  So,
generally don't do that.

Is there a reason you can't do tuple:["value", "value", "different value"]?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Russell Bateman  
View profile   Translate to Translated (View Original)
 More options Aug 23 2012, 10:34 am
From: Russell Bateman <r...@windofkeltia.com>
Date: Thu, 23 Aug 2012 08:34:08 -0600
Local: Thurs, Aug 23 2012 10:34 am
Subject: Re: [mongodb-user] Re: Tuples in Mongo document with same key?

Thank you for responding. I think I just wanted confirmation--to make
certain that I wasn't missing out on something that could be
(appropriately) done. I have indeed decided to use an alternate
representation, possibly the one you suggest or maybe just a
space-delimited string (since the values I really want are identifiers
with no spaces or punctuation rather than what my example showed).

Thanks, Kristina.

Russ

On 8/23/2012 8:22 AM, Kristina Chodorow wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »