[02:24:20] <krz> http://pastie.org/4071109. it will always push to the array 'visits', if visits is an existing array. which is fine. but what if i wanted to $push to visits, only if name foobar did not exist. if it did, then just update the token. what should i be using?
[02:31:24] <whaley> is there a way to initiate a replica set on a database from the java driver? (this is for some system tests where I'd like to have a replica set available but created at runtime of the tests since the databases are setup/teared down after test runs)
[02:33:34] <whaley> I'm going to assume it's a DB.command("rs.initiate({configstuff})"). Going to give that a shot.
[02:33:46] <whaley> thanks for being my rubber duck
[05:03:02] <carsten> the stupid pmxbot is still there? kick this privacy violating bot please
[08:39:24] <Saby> hi, i was wondering if it is possible to write a query which updates all records whose currentDate - previousDate > 2 hours in a collection
[08:40:26] <carsten> simple usage of $gt or $lt operators
[08:40:43] <carsten> unless currentdate and previousdate are two fields on the ojbect
[08:41:19] <Saby> carsten currentdate and previousdate are 2 date fields
[12:29:16] <spillere> i'm really new to mongodb, i have a simple question, i'm doing a foursquare app, and i want to save the user and all his checkins in a db
[12:29:28] <spillere> for his checkins, shout I do it as tags?
[13:23:25] <Industrial> Where did I go wrong with installing mongodb? I have both mongodb-server and mongodb-clients installed and the mongodb server is running but I don't see it in ps -e|grep mongo https://gist.github.com/1014dc4231f55a392f5f
[13:40:03] <multiHYP> my complain is towards mongodb java driver designers.
[13:45:04] <multiHYP> so here I read that the java driver is just a json parser: http://stackoverflow.com/questions/3580529/how-do-i-update-fields-of-documents-in-mongo-db-using-the-java-driver brilliant, what an achievement. :(
[13:46:24] <algernon> ("name.title" at insert time works the same in the shell as it does with java. that BasicDBObject(...) is longer than {...} is another detail.)
[13:46:40] <algernon> java is verbose. tough luck.
[13:52:41] <multiHYP> I know how to do it in shell, but not in java
[13:54:01] <multiHYP> algernon: no way, i don't know whether you used the java driver at all. java driver does not even support "detail.title" type of notation.
[13:57:06] <multiHYP> people talking out of … I rest my case.
[14:00:58] <multiHYP> I put my case back on the table. here is something perhaps new to algernon too
[14:02:16] <multiHYP> strictly java driver related: if you use $set, the "detail.title" notation nested in a "$set" works. otherwise it doesn't. So the only alternative in those cases is to pass a json object very similar to the shell command.
[14:03:28] <algernon> multiHYP: I still don't see your issue. update expects dotted notation, insert doesn't. same is true for the shell.
[14:03:32] <kali> multiHYP: honestly, i think you're confused.
[14:03:36] <algernon> nothing to do with the driver.
[14:04:23] <multiHYP> upsert without $set in shell supports dotted notation, but in java driver doesn't. <- I cannot express it more clearly than that.
[14:05:47] <spillere> im trying to connect using flask/python using db_connection = pymongo.Connection()
[14:55:42] <spillere> if exists db.id == 5 then...
[15:17:49] <m_rec> hi everyone, is there a reason rs.status() would no longer return stateStr when being run? since the replica set elected a new primary I can't seem to find that field anymore
[16:59:37] <c3l> If I have, in my collection, a document like the following, how do I uniquely identify a "subdoc"? {title:"Some Title", subdocs:[ {title:"Subtitle one", title:"Subtitle two"} ]} For instance, there is nothing stopping the subdocs from having the same title.
[17:02:08] <c3l> NodeX: Im quite new to mongodb, I dont really understand. Yes I would like to have some unique index for each subdoc. Should I manually set a "_id":ObjectId(..) key/val pair for each "subdoc"?
[17:04:10] <NodeX> you can do an upsert on subdocs.title
[17:04:19] <NodeX> or you can ensure a unqiue index on it
[17:05:38] <c3l> I cannot ensure that the titles (or any other field for that matter) will differ, since these can be manipulated by the user. What would be the best way to ensure a unique index on it?
[17:06:30] <NodeX> you can ensureIndex(); on it then
[17:07:37] <c3l> oh, I didn't know there was such a thing. Ill look into it, thanks!
[17:10:53] <NodeX> looks at unique:true,dropDups:true
[17:21:17] <skot> dropDups is dangerous as it doesn't define with dup will be kept
[17:43:24] <jshanks> I found that there is a hex_md5() function available on the server (for use in server side javascript), is there also a function for sha1 built in?
[17:44:45] <dotty> Hi everyone. I want to ask a question about MongoJS (Node.JS library) - should I ask here or in #Node.js?
[17:48:48] <dotty> I'll ask in both I guess. I'm attempting to connect to MongoDB using the following: "require('mongojs').connect('localhost');". This worked on my work machine but, now I'm on my laptop, it's not working and I'm getting the following error: "database name cannot be the empty string" - any clues as to why?
[18:18:04] <jshanks> Does anyone know if there is a built in sha1 function for the js mongo shell?
[18:26:05] <kali> jshanks: any javascript implementation should work, but i don't think there is anything builtin
[18:27:19] <jshanks> ok thanks kali. since there is a built in "hex_md5" function, I was hoping there was a built in sha1 function as well.
[18:29:29] <jstout24> question… which schema is better… we have visitors with attributes… here: https://gist.github.com/e185cc4a565948b00937
[18:30:01] <jstout24> my assumption is that 3 may be the best choice?
[18:46:29] <mkmkmk> i have a collection that has 1000-2000 writes/sec… they're actually upserts.. think of it like a unique visitor log.. if the entry doesn't exist, it's created and the _id is a standard mongo object id.. if it does, i $push a small string onto an array on the document.. im working on sharding it, but i need to figure out a good shard key for the visitors collection
[18:46:56] <mkmkmk> since im using objectid's for _id, that falls into the trap of pushing most of the writes to a single shard
[18:47:51] <Goopyo> Q: Is safe mode needed if journaling is enabled?
[18:52:02] <jstout24> mkmkmk, i'd like to know your solution when you find out
[18:52:06] <jstout24> that's exactly what i'm working on right now
[19:02:00] <dstorrs> That would ensure a roughly random distribution
[19:02:26] <mkmkmk> not tracking any of that except a unique id, which i was using objectid's for
[19:02:38] <mkmkmk> so is that what i should start doing? gen a uuid as well
[19:02:46] <dstorrs> another option would be to include an arbitrary field to the record that comes out of a call to rand()
[19:02:55] <mkmkmk> so _id : ObjectId, uuid: <uuid>
[19:03:01] <dstorrs> it has no meaning, except it makes a good shard key
[19:03:40] <dstorrs> fwiw, I'm in the same boat as you -- just migrating to Mongo, haven't done sharding yet, still figuring it out.
[19:03:49] <dstorrs> This is just my best understanding / thinking atm
[19:04:38] <dstorrs> and you must be storing SOMETHING other than the _id, or there's not much point in the collection. what else is in there?
[19:05:00] <mkmkmk> an array of stuff that has nothing shardable
[19:48:56] <dmuino> i need to do a mongorestore of a large collection on a sharded cluster. The collection + index will not fit on a single replset. I'm currently doing the restore but it seems that all the inserts are going to the first shard, and that will fail
[19:49:23] <dmuino> is there a way for me to get the writes going to all shards? (using mongo 2.0.5)
[19:54:33] <cjm> I'm getting this error, ReferenceError: message is not defined when trying to do a geonear command
[19:56:07] <dmuino> the shards were balanced before
[19:56:29] <dmuino> the dump i have is one that was taken from mongos
[19:56:54] <dmuino> the data does not physically fit in a single shard
[19:57:28] <dstorrs> dmuino: yes, but remember how the sharding works -- mongos looks at the shard key and writes the data to a chunk on the appropriate shard. when a shard starts to fill up, the balancer moves chunks to other shards.
[19:58:27] <dmuino> first i restored the config db, did a flushRouterConfig
[19:58:28] <dstorrs> if your shard key is something that constantly increases (e.g., a date), then all data will initially go to the right-hand shard
[19:59:16] <dmuino> it's a compound key - i have 'name', 'cluster', 'country' - and the data should be quite random
[20:00:26] <dmuino> and all the shards are pointing to my first replset
[20:00:37] <dstorrs> heh. there's your issue, then. :>
[20:27:04] <opra> i am having a hard time setting mongo up for connection through a remote host
[20:27:12] <opra> is there anything i need to change to the mongo conf
[20:47:29] <Xxaxx> hello. how can it be, after db.copyDatabase('vk_photolike', 'vk_photolike', '188.93.20.75') , source: vk_photolike 65.921875GB, destination: vk_photolike 7.9501953125GB
[20:55:51] <leandroa> hi, I have a doc like this: https://gist.github.com/2920068 and I need to add indexes for sorting by sortable_key.en-US and sortable_key.es-AR. What is better, an index to 'sortable_key', or many indexes by keys inside sortable_key?
[21:08:35] <BobFunk> having a really simple query on a pretty small capped collection take incredibly long, even though it should be a simple index lookup
[21:08:43] <BobFunk> documents in the connection are cached http requests
[21:09:09] <BobFunk> look something like {url: "http:...", response: "..."}
[21:09:29] <mediocretes> what are you querying on, and what does the index look like?
[21:22:48] <jstout24> i was just about to test dot notation
[21:22:52] <mediocretes> bobfunk: that'd be my next step if I were using the ruby driver, I think
[21:23:17] <jstout24> oh, mediocretes, but what if attributes.____ is dynamic
[21:24:03] <mediocretes> then I don't know what happens
[21:24:14] <mediocretes> index attributes, make some junk data, and use explain()
[21:25:34] <jstout24> but yeah, doing what you posted works if the field was known
[21:33:19] <csurap> how can I query a reference field using other that the ID
[21:33:55] <csurap> can I query with any other field like "user.name" instead of "user.$id"
[21:37:42] <BobFunk> hmm, ok - it seems that when I pick a new url the query takes forever, when I pick one that has been queried before, mongo uses the index and it's fast enough
[21:42:54] <BobFunk> hmm, seems the explain takes as long as the query :/
[21:57:21] <csurap> dstorrs: field user is an referenceOne document
[22:01:52] <jstout24> i need a mongodb genius… here's my problem and attempts at it: https://gist.github.com/eb72b04ce8990bd35b7e
[22:28:27] <BobFunk> really don't know what's up with that collection
[22:28:55] <BobFunk> even a query with a hinted index still takes forever - small collection, indexed field, straight forward query - 56 seconds
[23:17:13] <grafman> Mongodb newbie: I want to iterate over the all of the collections in a db. I'm getting the names using x = db.getCollectionNames(). I'm not seeing any examples on how the use the results or of a better way to interate over all of the collections in a single function.
[23:31:32] <grafman> I'm a mongodb beginner. I want to iterate over the array db.getCollectionNames() gives me. Does anyone have a pointer to how this is done?
[23:33:27] <mediocretes> note: there is nothing special about forEach or the function being passed to it. l = function(x){ … } ; db.getCollectionNames().forEach(l); will work just fine, because it's just javascript
[23:34:28] <mediocretes> you might also enjoy this: for each(var x in db.getCollectionNames()){ print(x);}
[23:35:36] <grafman> Is there a way to iterate over all of the collections? I have a find that will return the last inserted document that I want to run on each one.
[23:36:04] <grafman> like db.collection() or something?