[08:36:55] <kephu> I got a bit of a noobish question: I want to write a backend-to-a-game sort of a system, with badges and achievements and such. Being new to mongodb, I wonder, if it's better to store badges and achievements as sub-documents to the user document, or their own collection?
[08:37:42] <kephu> if it helps, I'm expecting potentially a lot of users, and, at least initially, just a couple of achievements
[08:38:21] <kali> kephu: you need to think your data in terms of queries instead of statically
[08:39:22] <kephu> kali: like I said, noobish question ;) How would I approach that from the query standpoint?
[08:39:24] <kali> kephu: try to figure out what the most frequent queries will be, and what layout will be optimum
[08:40:49] <kephu> kali: well when you put it like this, the "embedded doc" seems like the way to go. But then again, there's gonna be a dashboard component to it
[08:42:27] <kephu> well, like an administrative bit that lets you see how many users have achievement x, which ones are consistently topping the leaderboards, stuff like that
[08:42:49] <kephu> preferably with nifty diagrams and whatnot, but that part's on me entirely :P
[08:44:42] <kali> well, if it is on the administrative size, the scalability is less critical. i assume most stuff will be achievable with the aggregation pipeline or map/reduce, but that may be too slow for your taste
[08:44:48] <kephu> another noobish question, then: does mongo allow me to group by username, and then by achievement type? Provided the layout's like {username: 'some_user', achievements: [{name: some_achievement, ...}, ...]} ?
[08:45:04] <kali> denormalizing the required keys figures may help
[08:45:18] <kali> and yes, that is what the aggregation pipeline is about
[08:45:34] <kephu> will probably have to look into that then
[10:29:58] <Quest> why putting all data in one table is prefferd?
[10:30:09] <Quest> why not normalize or use 2 or more qureies
[10:30:42] <Derick> because in MongoDB you store your data from an applications point of view, and it makes no sense to do two queries if you don't need to.
[11:49:08] <richthegeek> I've got some badly-saved data in my db (numbers stored as strings) and I'm wanting to do an aggregate $sum on these fields - is there any way to make it work (ie, make the driver assume that $sum fields should be at least considered as numbers) or is there just no way?
[11:51:13] <Nodex> richthegeek : I don't think there is a way, on the plus side you can just loop it and fix the data
[12:30:58] <bla> I want to create a collection with distinct entries of a field from other DB.
[12:31:16] <bla> Previously on few fields I did .distinct() and then using a loop just reinserted into new DB
[12:32:00] <bla> But now distinct fails on 16mb limit and I've got no idea how to do it - except for writing external software.
[12:33:08] <ranman> bla: internally distinct creates a document and if there are more than 16mb worth of distinct values it's going to hit the document size limit
[12:33:46] <ranman> so yes, you may need to just write some external python script
[12:34:08] <bla> Can I create a collection with unique index on value and use map reduce to fill it?
[12:34:35] <ranman> sure but I would suggest doing it in batches rather than trying it all at once
[12:48:55] <emans> приветствую! есть русско-язычные?
[13:36:01] <bin> so the only way to configure rs is within mongoshell
[13:36:39] <Derick> bin: it has to be in config files << that made no sense
[13:36:51] <Derick> bin: it has to be in the replicaset config on the servers to make adding new nodes easier... and not have stale config files all over the place
[16:17:29] <movedx_> Can you place a constraint on a document's fields? For example, can I place a constraint on a field that prevents an integer less than 0 or greater than 100 from being applied, or do I have to do this in software?
[16:20:08] <movedx_> That's cool! Makes sense. I was just wondering :)
[16:36:30] <prateekp> hello, i am building a rails appliction . I am using mongodb .... While i am able to access the database from console but the things are not running on the application
[18:42:45] <ericsaboia> But aggregation comparsion operators do not accept "$in"
[18:43:19] <ericsaboia> is there any way to do that without map/reduce?
[18:56:56] <link1511> hey all, i'm trying to diagnose an autoreconnect error with pymongo
[18:57:07] <link1511> i have newrelic on the mongo hosts, and on the host that is querying them
[18:57:18] <link1511> and i don't see anything that looks like an issue in the numbers on the mongo side of htings
[18:57:28] <link1511> but the autoreconnect error seems to indicate that a replica set has failed?
[18:57:38] <link1511> what kind of things should i be looking for to indicate a problem in mongodb
[19:06:48] <lakmuz> have collection {_id: ingridient, productIds: idsofproducts}, need to update this row by add new product id to productIds if exists or create new
[19:35:33] <maplebed> Hi, I'm looking for the changelog for the mongo gem. Docs point to https://github.com/mongodb/mongo-ruby-driver/wiki/History but that page doesn't exist. Any suggestions?
[20:16:47] <ericsaboia> But aggregation comparsion operators do not accept "$in"
[20:16:50] <ericsaboia> is there any way to do that without map/reduce?
[20:22:27] <dnsdds_> I have an array of documents I want to insert to a collection with a unique index. Some documents are identical to existing documents, some aren't. What's the path of least resistance to insert only the ones that aren't already there?
[20:27:34] <luimeme> i try to do an upsert it work well except it remove a field that is on the document but not in the value i upsert how can i update only the field of the upsert and leave the other intact please
[20:28:58] <Joeskyyy> dnsdds_: you mean something like upset?
[20:30:54] <luimeme> Joeskyyy, i use $set but it delete one of my field
[20:31:19] <luimeme> Joeskyyy, db.hosts.update({'name': id},{'$set' : data },True)
[20:31:25] <dnsdds_> Essentially, I have incoming documents with a single field called "tags" that have CSV data in them ("foo, bar, derp"). I split it with ", " to make an array of tags, and I want to add each tag as a separate document in my tags collection
[20:32:01] <dnsdds_> I can do a bulk insert, but what if "foo" already exists? Doesn't that mean that "bar" and "derp" won't get inserted because the unique flag failed for the first one?
[20:37:33] <luimeme> nevermind i was something else :)
[20:38:36] <Joeskyyy> dnsdds_: Can you expound a bit more? Are you just adding "foo" "bar" and "derp" to a general tags collection, and checking to see whether any of them exist?
[20:39:28] <Joeskyyy> i.e. in your tags you currently have "foo" "bar" "cats" , so if you sent in "foo" "bar" and "derp", it checks to see which of those exists, if it doesn't exist, insert it? (in this case "derp")
[20:39:54] <dnsdds_> Joeskyyy: That's the gist of it, yes
[20:40:45] <dnsdds_> Joeskyyy: But I'm guessing there should be a smarter way to do that than to just loop over the array and separately .find() each tag and .insert() if it doesn't exist
[20:40:56] <Joeskyyy> Are your tags just stored in an array of some sorts in mongo?
[20:41:37] <Joeskyyy> If so I'm hinting at $addToSet if that's a possibility
[20:41:38] <dnsdds_> Joeskyyy: in the actual items collection, it's just a CSV-style String for presentational purposes. In "tags", it's separate document for each tag
[20:52:10] <dnsdds_> "Drivers have a ContinueOnError option in their insert operation, so that the bulk operation will continue to insert remaining documents in a batch even if an insert fails."
[20:56:21] <Joeskyyy> kind of a janky workaround but 2.4 has a setOnInsert when running an update, I'm not sure how fast this would get you but it does work
[21:44:33] <qswz> If you directly map user/clients json requests (like that: [action, token, collection, json1, json2]) into mongo queries, what are the potential danger? given that 1- collections names are prefixed with "test.", 2- only 3 mongo methods accepted: find, remove, update (upsert mode), and 3- there is an access, update and remove-rights for documents
[21:44:58] <qswz> the danger I still see is people doing extremely long queries
[22:39:20] <ericsaboia> hey guys, I need to sort users based on a list of ObjectIds, I'm trying to use aggregation with project to accomplish that