[00:45:20] <ranman> brucelee: you can set read concerns to
[00:45:49] <ranman> brucelee: if you have a read concern like "primaryPreferred" it will read from the primary if it's available or a secondary if it's not
[00:46:09] <ranman> brucelee: or you could do secondaryPrefered and it would try to minimize the number of reads hitting the primary
[00:46:16] <ranman> brucelee: there are read concerns and writeconcerns
[02:14:20] <shesek> Hey. I'm thinking of using mongodb for user notifications pub/sub, with a capped collection and a tailable cursor. Do you think this is a good idea, or should I be using something more specialized for this purpose?
[02:18:38] <Mark_> i think thats probably not a good use case
[02:18:44] <Mark_> but im finding mongo usage pretty narrow myself
[02:19:03] <Mark_> youd probably be better off with redis for your usage
[02:19:43] <Mark_> i think of mongo like a key/value store on steroids with a bit more structure
[02:20:09] <Mark_> but theres free mongodb providers, so sometimes i use it even though mysql or postgres would be better
[02:21:29] <shesek> Mark_, the thing is that I do need to persist those notifications anyway, until the users go and read them. so its really a combination of persistent storage + immediate notification (pushed to clients via a websocket)
[02:21:35] <shesek> which doesn't really fit redis
[02:21:52] <shesek> I could use mongo for persistent storage, then something else in addition to that for the pub/sub
[02:22:33] <shesek> but... I dunno. I would rather not introduce a separate technology just for that if I could handle that with mongo as well
[02:23:22] <shesek> ... unless other solutions have compelling advantages over mongodb that justifies it
[02:24:36] <shesek> I know it can (I'm using redis on some other projects), but I don't feel like what I'm doing here really the intended use case for redis
[02:25:38] <Mark_> well, i think you can probably bend any of them to your will
[02:25:44] <Mark_> its a matter of convenience i suppose
[02:25:59] <Mark_> at its core it sounds like you can distill your need to
[02:26:11] <Mark_> 'a list of people each with a list of shit to send them'
[02:26:25] <Mark_> theres not much need for further relationships
[02:26:54] <Mark_> i dont think redis or mongo really have much speed difference or functional difference in persisting that usage
[02:27:06] <Mark_> the mongo php driver is better than the redis landscape, so if it were php id use mongo,
[02:27:14] <Mark_> those are the types of factors id be thinking of for something like that :P
[02:39:25] <Mark_> why did i use mongo? because it was a free option
[02:43:15] <shesek> Mark_, thanks for your input. you're definitely right, those considerations can definitely be more important than which technology is "better" in many cases
[02:44:03] <shesek> it looks like its somewhat of a pain with mongodb though, because you can't keep a tailed query on an empty collection
[02:44:43] <shesek> I'm thinking that I'll probably store it as documents on mongo, and use something separate just for the live pub/sub
[02:47:54] <Mark_> havent been too deep down that road though
[04:41:24] <in_deep_thought> what are the elements in a .find() query sorted by if no .sort is given?
[06:28:18] <shesek> How would you go about this: I have a list of notifications for users, with a state of read/unread. I want to periodically delete old read notifications, but always keep the last 5 notifications. For example, if I have 3 unread notifications and 7 read notifications, I would want to delete the 5 oldest read notifications to end up with a total of 5 notifications (3 unread + 2 read)
[06:29:21] <shesek> would I have to implement this login in app-land, or could I get that logic into a remove() query and let mongodb handle that?
[12:11:49] <kali> Aswebbb: yeah, you need to create the index before using it
[14:27:03] <topwobble> We store timezone as seconds_from_gmt but are changing to using a number between 0 and 23. I need to modify every document in a collection by modifying the timezone property by a function. I am worried that this collection update will take a long time and block mongo (we have 4+ million documents). Will “db.users.update({timezone: -18000}, {timezone: 23}, {$multi: true})” block mongo while it is running?
[14:28:47] <Nodex> why not clone the collection to another db ?
[14:30:56] <rspijker> topwobble: first off, better use a $set there. Second, the write will in principle lock the DB (but there is yielding of locks in some cases)
[14:33:18] <topwobble> Nodex: idk how to do that :D
[14:33:37] <topwobble> rspijker: ok. how do i know whether this will yield?
[14:33:50] <rspijker> it yields when it has to hit disk, for instance
[15:02:46] <jillesme> Hey guys, is a collection comparable to a table in SQL?
[15:06:57] <jillesme> Nodex: thanks, you're awesome! I want to create a yes/no app in node and mongodb.. This is my initial db 'design' http://vpaste.net/iWIkE
[15:07:08] <jillesme> Do you have any comments on it? Am I approaching it right?
[15:11:49] <Nodex> just be aware of the 16mb document limit
[15:12:12] <kali> you may want to maintain a count of both types of votes as a separate field
[15:17:12] <jillesme> Will this affect speed much?
[15:17:22] <jillesme> Compared to, for example MySQL
[15:18:45] <kali> it depends how you do it. this blog post is not dealing strictly with the same issue, but it can give you an idea on how to scale http://blog.mongodb.org/post/65612078649/schema-design-for-social-inboxes-in-mongodb
[15:19:49] <kali> also, note that your current schema proposal will handle several hundreds of voters as is
[16:41:42] <shinDog> i have a collection that's littered with objectid references but I want to make them embedded, what's the best way to go about doing that? I thought about looking up the document by its ID and inserting/replacing it in the original document but I can't find any info on how to do that which makes me think I'm barking up the wrong tree..
[16:42:50] <test123> are the references all within the same collection?
[16:44:51] <shinDog> nope, in a Book-Author example I've got all the Authors as objectid references held in the Book documents
[16:45:42] <shinDog> the database is live so I'm looking for a migration strategy
[17:01:38] <test123> I don't know that much but can you just find each doc by the id?
[17:02:49] <test123> Then take the results of the find and insert that
[17:06:04] <jillesme> I can't start and restart mongo :(
[17:15:40] <shinDog> thanks - i'm getting somewhere now, I didn't understand before that find() returns a cursor to iterate over the documents so the results of find() was confusing me
[17:16:35] <jillesme> Does someone see a 'register' button? http://dochub.mongodb.org/core/startingandstoppingmongo
[17:30:49] <arussel> I'm doing an update on an object, is there a way to say: set field 'a' to max(currentValue, 5) ?
[17:34:54] <kali> arussel: http://docs.mongodb.org/manual/reference/operator/update/max/#up._S_max brand new in 2.6
[17:35:20] <arussel> thanks, I was reading: https://jira.mongodb.org/browse/SERVER-1534
[17:35:31] <arussel> but couldn't find it in the doc
[17:38:47] <jillesme> MongoDB is so awesome I want to die
[17:40:26] <Aswebbb> it returns also the other fields
[17:40:37] <Aswebbb> even if I specified that I only want "email" and "username"
[17:46:16] <tskaggs_> Hey! I just got a two csv dumps: locations.csv and product.csv. Originally the associate was made via IDs (location ID 1 has products with ID 1). I'm using the 'owner' field in the products to work with node. So the products has for example "owner": 1. The Location's ID was changed when I imported them into the Mongodb but I made a field called 'original_id' to keep that handy. now I need to update the product 'owner'
[17:46:16] <tskaggs_> field to be the location's mongo ID.
[17:47:24] <tskaggs_> Is there a way to query location 'original_id' and match it with all the products with the matching 'owner' and then update the product's 'owner' with the new location 'id'?
[17:52:50] <JoeyJoeJo> Does Mongo have write locks (ie can two things write to the DB at the same time)?
[17:58:25] <cheeser> JoeyJoeJo: yes it does and no.
[18:44:26] <tongcx> hi guys, is there javascript library which can parse sth like '{"time": {"$date": 123456}}' into proper object?
[19:11:51] <Zelest> kali, any feedback regarding this layout: http://pastie.org/private/32dqjjbs3rtcaxaltpywq
[19:12:07] <Zelest> the actual data is stored in a separate collection
[19:35:33] <arussel> I set a field to a value 'x' -> 'a'. once the value is chosen, the client will always set it to the same value, so only the first set is significant.
[19:36:26] <arussel> would it be better to first do a read and then set if this is not set or just write everytime ? what should I take into account to have a meaningful answer ?
[19:54:46] <locojay> does find({}) use a pagination of size limit internally for large collections...
[19:55:41] <cheeser> it gives you a cursor with a default batch size (20, iirc)
[19:58:14] <locojay> thanks i can just next on the cursor and pass to a lazy sequence...
[19:59:08] <cheeser> your driver should handle that transparently for you
[19:59:21] <locojay> mongodb-erlang misses alllot of love ;)
[20:45:54] <toraRTC> I keep getting "not authorized on admin to execute command" when trying to add a user to the admin db, I can't figure out how to authorize mysel
[22:06:51] <durango> I have a slug field such as my-slug-13, my-slug-7, how can I check for the "highest number" from my-slug-X?
[22:12:18] <fl0w> I have a bunch of documents with the following structure (excerpted) https://dpaste.org/TZy9 and I would like to re-order these (changing the pair value of order) within the document. I don’t care about the order of the array (unless there’s a reason to?). My real problem is here that I need to have it anatomically (isolated?) changed. How could I accomplish this? Or am I just chosing the wrong tool for this problem?
[22:14:25] <fl0w> I understand when updating a document it’s atomic - but I can’t really re-calculate the order for each object (sub-document really) within the query? I need to do it at application level, which basically requires me to do a manual “lock”? Or can I do it some other way?
[22:19:20] <bel3atar> I have a collection like this http://ix.io/bUx . How would I calculate the sum of outs for lot 1?
[22:21:02] <fl0w> bel3atar: do you have to do it in query?
[23:08:15] <jjsam> Does MongoDB support mutable BSONObj in C++? From https://github.com/mongodb/mongo-cxx-driver, I am not finding the mutable BSON API. But https://jira.mongodb.org/browse/SERVER-8046 says it is already fixed in 2.5.1. Is it wrong?
[23:11:37] <ranman> bel3atar: mostly the fact that it has to push everything into the javascript engine to do work
[23:13:54] <jjsam> ranman, are you saying C++ API is less capable than JavaScipt API?
[23:37:46] <Zelest> How can I fetch an object and return only a single element of an array.. the array contains objects with a ISODate() and I want the oldest object in that array.. is that possible in a single query?
[23:53:36] <shanlar-> what is the best driver to use for delivering images out of gridfs?
[23:54:18] <shanlar-> ive read nginx-gridfs is not async and blocks on requests
[23:55:26] <shanlar-> i currently have 700gb of user images i am looking into moving to gridfs. simplify replicas, DR, and backups.