PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Sunday the 4th of January, 2015

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:37:56] <barque> joannac, I don't know ... just a thought
[00:38:08] <barque> just curious, you're *sure* right ? :)
[00:38:29] <barque> I mean efficient over for example using the C++ Driver
[01:47:21] <AronBrrr> hey all, i’m having some trouble figuring out the best way to store nested data in a mongo collection
[01:47:48] <AronBrrr> it seems like having arrays nested in a document is kinda hard to deal with
[01:47:59] <AronBrrr> i want to do something like:
[01:48:40] <AronBrrr> ugh, hold on
[01:55:37] <AronBrrr> http://pastebin.com/0mKX075k
[01:56:31] <AronBrrr> so i have a collection of, say, television shows, and inside each show is a seasons array, which contains info about each season, and inside each season object, there’s an array of episode objects. is this a good/bad way to do it?
[01:56:53] <AronBrrr> or should i have an episodes collection and then a tv shows collection? and link them somehow?
[04:54:01] <torarch> is there much sense in terms of efficiency to split a users collection into guest users and permanent users? I am getting large quantities of guest users which I expire based on a sparse index on a field that only the guest users have
[04:55:08] <torarch> there are some unique indexes that are applied to the user collection which dont need to hold for guest users
[14:15:17] <Patteh> i've got a db connection setup with mongoose
[14:15:24] <Patteh> but i need to use mongodb's batch insert functions
[14:15:32] <Patteh> must i create a new connection for mongodb native to use
[14:15:38] <Patteh> or can i utilise mongoose's
[14:15:49] <Patteh> or vice versa (create connection in mongodb and have mongoose use it)
[14:43:44] <mordof> Patteh: http://stackoverflow.com/questions/10519432/how-to-do-raw-mongodb-operations-in-mongoose
[14:44:13] <mordof> Patteh: i'm not sure about actually using the current connection with the other module though
[14:49:46] <Patteh> its okay i'm just trying to save the objects directly as they are created now
[14:49:52] <Patteh> getting a new error :D
[14:50:01] <Patteh> [TypeError: Cannot call method 'save' of undefined]
[14:50:50] <Patteh> http://pastebin.com/wThCcpn8
[14:52:53] <mordof> you need to use return - node doesn't automatically return values
[14:53:10] <mordof> so you're not actually providing the Article entity to whatever called it
[14:53:12] <mordof> (currently)
[14:53:15] <mordof> hence the undefined
[14:55:29] <Patteh> aha
[14:55:29] <Patteh> ty
[14:55:43] <mordof> you're welcome :)
[14:56:08] <mordof> Patteh: you wouldn't happen to know about the geospatial indexes mongo has would you?
[14:56:30] <mordof> trying to find an answer to my question, and haven't had any luck in this channel so far unfortunately
[14:56:36] <mordof> (or anywhere for that matter)
[14:57:26] <Patteh> i wrote my dissertation on geospatial representation software
[14:57:31] <Patteh> but that was 10 years ago :D
[14:57:44] <Patteh> this is the first time i've used mongo or node so no use to you i'm afraid
[14:57:50] <mordof> well - maybe you'll be able to help my idea of what i'm trying to do either way
[14:58:00] <mordof> because this is the first i've tried to do anything with geospatial stuff at all
[14:58:06] <Patteh> usually gets busier on freenode when the americans wake up
[14:58:11] <mordof> indeed
[14:58:30] <mordof> i'm on EST - but i wake up at my 'work time' just out of routine, heh
[14:59:39] <mordof> so i've got a bunch of different items in several different collections that are holding x, y values (indexed with generic 2d index in mongo). my thought was that if i held a box (2 tuples or w/e they're called), that i could query a "is this point inside any user box"? type of thing
[14:59:56] <mordof> so as to find out which user needs to be alerted when an item in a collection gets updated
[15:00:36] <mordof> essentially all i've been trying to determine for the past week or so, is if that's a good idea, and if so - can mongo do that with "normal" 2d indexes
[15:01:07] <Patteh> what is the requirement? local event alerts for users?
[15:01:39] <mordof> it's a game for the sake of testing out node+mongo and other processes working together. so the user is looking at a current location, and if something gets updated - they should see that come up
[15:01:47] <mordof> socket io for web transmissions
[15:02:19] <mordof> so i'm trying to determine a decent way to mark that a user should receieve updated info
[15:02:42] <mordof> without just having the client request all data every few seconds or something, lol
[15:02:46] <mordof> (it's not quite real-time)
[15:03:07] <Patteh> yeah would be a bit tricky getting full realtime
[15:03:22] <Patteh> that sounds like plausable logic
[15:03:37] <Patteh> but in terms of implementation with mongo/node i wouldnt know
[15:03:37] <mordof> the whole architecture/process for the game has been geared towards allowing for latency issues and certain timeouts and whatnot, so that part is fine
[15:03:40] <Patteh> about efficiency
[15:04:00] <mordof> alright - well that helps me either way, thanks :)
[15:04:13] <mordof> been wondering if i'm trying to do something too unusual and that's why i can't find anything, lol
[15:04:35] <mordof> node's documentation on this subject is very annoying/not all that clear :/
[15:04:38] <mordof> er
[15:04:39] <mordof> mongos
[15:05:59] <Patteh> so i've added my return which has squashed all errors
[15:06:09] <Patteh> but still not getting anyhting in my articles collection
[15:06:23] <Patteh> the objects are being built, i've tested that
[15:06:28] <Patteh> but collection remains empty
[15:06:51] <mordof> you're sure you are connecting to the right database to check the contents?
[15:07:01] <mordof> i think mongo defaults to some test db or w/e
[15:07:20] <mordof> when connecting through commandline (that's messed me up the first few times i tried to look for stuff)
[15:07:59] <mordof> it should be putting it in the 'articles' collection
[15:08:53] <mordof> ah you mentioned the collection name. so that's correct. hmm
[15:10:31] <Patteh> ah no
[15:10:33] <Patteh> seems to be in there
[15:10:41] <Patteh> just not showing up in mongo explorer
[15:11:05] <Patteh> its a webstorm plugin
[15:11:05] <mordof> i tend to just use command line if i need to check something
[15:11:21] <Patteh> i was cajoled into using an IDE for the first time in years
[15:11:27] <mordof> heh
[15:11:31] <Patteh> undecided if i prefer it or not
[15:12:05] <mordof> i'd say it's a hindrance - depending on what type of projects you work on.
[15:12:11] <mordof> for databases in particular anyway
[15:13:02] <mordof> i generally have to jump on random remote boxes in production to check data quality and ensure records are there, so if i only knew the IDEs for the databases I work with... well that wouldn't work at all
[15:14:13] <mordof> i suppose a person can learn both well. generally that only occurs through necessity either way though
[15:15:34] <modulus^> IDEs for mongodb???
[15:15:42] <mordof> lol
[15:16:22] <mordof> imo mongo is the easiest database i've used to interact with command line
[15:16:27] <modulus^> it's just a JSON parser?
[15:19:28] <mordof> modulus^: do you know anything about geospatial indexes?
[15:19:32] <Patteh> IDE is for node
[15:19:40] <Patteh> it just has a mongodb explorer
[15:21:26] <mordof> https://groups.google.com/forum/#!topic/mongodb-user/LTt53Ki4Rug this is similar to what i want to do, without the need for the $near in the query... but i don't want to use lat/lng - and i'm wondering if this is possible to be done NOT based on a sphere (or if it's not, does it even matter?). i want to use x, y values with currently undetermined min/max limits
[15:24:15] <modulus^> mordof: what are you trying to accomplish?
[15:25:24] <modulus^> Patteh: nodejs?
[15:25:42] <mordof> modulus^: i'm making a game - user has a viewport (area of space they see). it's all 2D. each document in a collection has an x,y location for it. i want to update a user with new info if a document within his viewport has been updated
[15:26:14] <modulus^> mordof: are you writing a 2d physics engine?
[15:26:21] <mordof> modulus^: no
[15:26:48] <mordof> well
[15:26:50] <mordof> stuff moves
[15:27:17] <mordof> but there's not really any gravity (in most scenarios) or other factors on the objects
[15:27:44] <modulus^> sounds complicated
[15:28:40] <mordof> modulus^: i figured if i stored a polygon for the user's viewport, then each time a document gets updated - i could update that user's document to say "i need to update" and only then send new data to the user
[15:28:48] <Patteh> modulus^: yes
[15:29:37] <mordof> modulus^: by doing a $geoWithin. but the part i don't know about is if that *always requires* lat/lng and calculates on a sphere. the documentation is not clear on this
[15:35:44] <mordof> oooh\
[15:35:53] <mordof> legacy 2d supports a box and geoWithin
[15:36:00] <mordof> finally found that in the docs, lol
[15:36:02] <riceNbeans> "Unexpected token . " in return Foods.find({Session.get(foodCategory): {$in: [true]}}); What is wrong here?
[15:36:16] <riceNbeans> Session is a variable from my project
[15:36:26] <riceNbeans> object*\
[15:36:48] <mordof> riceNbeans: is it possible your foodCategory session variable is an invalid key?
[15:38:19] <riceNbeans> mordof: I don't believe so, I will double check though
[15:49:45] <mordof> ugh.. the legacy 2d box is only supported in querying, not storage. not what i need
[17:44:51] <rogero> Hi
[17:45:14] <rogero> Im using pymongo as a wrapping library around mongodb driver
[17:45:27] <rogero> I use this command to update some document in a collection
[17:45:31] <rogero> DB.USERS_INFO_COLLECTION.update( {'_id':_id}, {'$set': user_info_update} )
[17:45:57] <rogero> where user_info_update is a dictionary with the keys and values to be updated
[17:46:54] <rogero> my problem is: the above line removes the other entries in the document but the updated ones, why would that happen?
[17:50:00] <iraycd> rogero: removes other entires? Everything except that?
[17:51:06] <iraycd> rogero: is user_info_update a json object?
[17:51:06] <rogero> iraycd: it removes other key/value pairs but the ones updated
[17:51:16] <rogero> yes
[17:52:06] <rogero> iraycd: user_info = dict( last_operation=datetime.now() , abc='hi' )
[17:53:10] <rogero> iraycd: which generates: {'abc': u'hi', 'last_operation': datetime.datetime(2015, 1, 4, 17, 45, 53, 428148)}
[17:53:28] <rogero> what am I doing wrong?
[17:53:30] <iraycd> Which version of pymongo are you using? 1.8?
[17:53:44] <rogero> I think the latest, let me check
[17:55:28] <rogero> pymongo.version
[17:55:30] <rogero> '2.7.2'
[17:57:30] <rogero> iraycd: is that version problematic ?
[17:58:14] <iraycd> iraycd: I had the problem with old version. Now, I have no idea.
[17:59:19] <iraycd> rogero: I had the problem with old version. Now, I have no idea.
[17:59:57] <rogero> well, at least I know the command is fine :) isn't it?
[18:00:35] <iraycd> Yeah, it is, but if it applied on multiple objects. You have to include { multi: true }
[18:01:19] <rogero> it's intended to be applied to only one document
[18:02:44] <iraycd> rogero: Then the command is fine.
[18:14:01] <rogero> iraycd: what if I use the update command without $set parameter?
[18:14:06] <rogero> should it be fine?
[18:15:17] <iraycd> rogero: You can't do that, because set is like a command in background. There are many other operations.
[18:15:19] <iraycd> http://docs.mongodb.org/manual/reference/operator/update-field/
[18:16:18] <iraycd> Most of the time I use set, unset, rename.
[18:16:56] <rogero> I see
[18:17:24] <rogero> Thanks a lot :)
[18:21:37] <iraycd> rogero: This is what update does in pymongo. https://github.com/mongodb/mongo-python-driver/blob/master/pymongo/collection.py#L415
[23:31:26] <vagueBrother> hey all, can anyone recommend any techniques or patterns to storing nested data in a mongo db?
[23:31:48] <vagueBrother> i’ve been having some odd problems with querying data that is objects nested inside arrays nested inside objects
[23:37:37] <Boomtime> how about you describe your current document schema and the 'odd problems', maybe we can help with those instead