PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Monday the 28th of July, 2014

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:08:16] <joannac> ranman: cool
[06:28:06] <meadhikari> Hi guys, I am trying to build an API, how do I handle DBRef in json, i am using mongoose, please help i am stuck
[06:31:11] <joannac> meadhikari: http://mongoosejs.com/docs/populate.html
[06:36:13] <meadhikari> joannac, i was given a schema with dbref in it, i need to make an API with CRUD from http requests, how do i handle dbref when i send data through json? Am I thinking this wrong? please help
[06:39:21] <joannac> I don't understand the question, meadhikari
[06:39:40] <joannac> what do you mean by "how do I handle DBref?"
[06:39:59] <joannac> how do you process it? How do you save it in mongodb? what exactly are you asking?
[06:40:31] <meadhikari> send it as json in post request and save it in mongodb
[06:41:30] <joannac> you want to know how to turn a DBref into valid JSON?
[06:42:01] <meadhikari> yes that
[06:42:08] <meadhikari> i have the schema like https://gist.github.com/meadhikari/34b788bfd0c48aa2b3b8
[06:42:25] <meadhikari> i want to do crud in this collection through http requests
[06:43:05] <meadhikari> if there was no dbref, i would do it pretty easily but now i am confused how to handle it, make it valid json
[06:43:30] <joannac> That's all explained in the page i linked
[06:44:04] <joannac> specifically, you create objects, assign them, and mongoose takes case of the details
[06:48:31] <meadhikari> joannac, in json i create key as "_key" and attribute as the id of the object i am referring to?
[06:52:01] <joannac> meadhikari: if you want to make your own Dbref, look here: http://docs.mongodb.org/manual/reference/database-references/#dbrefs
[06:52:25] <joannac> If you want to make you own manual reference, do whatever you like
[07:15:06] <meadhikari> joannac, thanks for your time. I got it working
[08:11:19] <meadhikari> Hi guys, I am using mongoose keep getting "Error: Cannot use a writeConcern without a provided callback" my code is https://gist.github.com/meadhikari/97b436d0cd32700d2c09 please help
[08:12:58] <cheeser> i'm not a big js guy but it looks like you don't define callback until after you've "passed" it to update()
[08:16:40] <meadhikari> cheeser, this gives same response https://gist.github.com/meadhikari/97b436d0cd32700d2c09
[08:17:34] <cheeser> does it point at a line?
[08:18:54] <meadhikari> cheeser, yes the update() line
[08:20:21] <cheeser> hrm. yeah, i'm out of guesses.
[08:34:49] <rspijker_> are you sure that’s your exact code meadhikari ?
[08:34:54] <rspijker_> because it looks fine as is
[08:35:14] <meadhikari> rspijker_, that is exactly my code
[08:43:00] <meadhikari> thanks for your time guys, i solved it
[08:43:05] <rspijker_> what was it?
[09:33:58] <meadhikari> rspijker, insted of using the model object i was creating another schema object
[09:37:16] <rspijker> I see
[09:54:15] <KamZou> Hi, i've an issue with an index on a secondary RSM : http://pastebin.com/eAwgiWAt So i tried : http://docs.mongodb.org/master/tutorial/build-indexes-on-replica-sets/ But when i'm trying to create an index on the collection and field i was warned about, mongo tells me index is already existing on field _id Any idea please ?
[09:56:58] <rspijker> KamZou: you already have an index on _id, but it’s not unique?
[09:57:43] <KamZou> rspijker, hmmmm so the issue is that it's not unique ? How could i ensure that ?
[09:58:43] <rspijker> KamZou: http://docs.mongodb.org/master/tutorial/create-a-unique-index/
[10:00:56] <KamZou> ohhh thanks !
[10:27:53] <dawik> hi. is it possible to create a date object from the C driver?
[10:27:55] <dawik> somehow
[10:32:26] <rspijker> dawik: http://api.mongodb.org/c/0.3.1/bson_8h.html
[10:33:36] <dawik> rspijker: ah, bson_append_date, should've guessed. thanks!
[10:35:12] <rspijker> np
[11:46:20] <bin> hey guys
[11:46:59] <bin> i updated to 2.6.3 and i still don't have initialize[Unordered/Ordered]BulkOp() available as a method of my collection
[11:47:02] <bin> any ideas why'\s that
[11:47:02] <bin> ?
[11:50:11] <AlexejK> Spammers now reaching mongoDB JIRA as well? https://jira.mongodb.org/browse/JAVA-710?focusedCommentId=673390&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-673390 or is it just me not understanding a single word of the comment? :P
[11:54:20] <kali> AlexejK: I think you're right :)
[12:26:06] <zack___> If I have one class but it is called differently by two methods and I wanted to store that class in Mongo
[12:26:23] <zack___> How would I differentiate how it was used by having two different collections based on that one class in mongo?
[12:26:25] <zack___> I'm using Java
[12:27:06] <kali> zack___: well, it depends what you're using to tranform these java classes in mongodb docuents
[12:28:08] <zack___> In my dao I just have two different repos that extend MongoRepository<MyClass, String> and I have that in both repos
[12:28:25] <zack___> I want to avoid making that same class again and just naming it differently
[12:28:50] <zack___> Is there a way to specify the collection name without it being based on the classname?
[12:30:26] <kali> zack___: you're using spring's MongoRepository ?
[12:30:39] <zack___> Yes, sorry if that wasn't specified
[12:31:42] <kali> i can't help more, but maybe somebody with spring knowledge will jump in
[12:31:58] <zack___> I heard something about a @Document annotation.
[12:32:26] <zack___> I'm just wondering if it's possible to use one class and make two collections out of it that are named differently. Right now it just takes the class name and names the collection after that
[13:37:35] <bin> why using db.copyDatabase the copied database is with smaller size?
[13:48:32] <kali> bin: because it is defragmented along the way: see this http://docs.mongodb.org/manual/faq/storage/
[13:49:00] <bin> ahhhh i see so all of the free space is defragmented right ?
[13:49:07] <bin> and all documents are next to each other
[14:02:48] <bin> thanks kali
[15:29:42] <cozby> 4
[15:37:03] <Nodex> 6
[15:41:19] <nicolas_leonidas> is there a channel for mongodb under nodejs?
[15:41:28] <cheeser> this one!
[15:41:39] <nicolas_leonidas> I have some aggregation commands that work well in mongo shell, I'm trying to get them work under node
[15:42:14] <nicolas_leonidas> here is the command, help me enjoy my first mongodb super query experience :) http://paste.debian.net/112198/
[16:01:05] <Nodex> anyone know an online tool you can throw a block of text into and see which part is not UTF-8 encoded?
[16:01:25] <Nodex> got some weird stuff going on with seemingly encoded text and mongo going mad aboout it
[16:03:04] <Derick> Nodex: I can look at it :-)
[16:03:45] <Nodex> Mind if I pm the link to a pastebin? - it's got emails and phone numbers in it
[16:07:47] <Nodex> so'k actually. I'll just run the whole array though a converter, it's not that big
[16:56:33] <jParkton> after I switch to a collection how do I show all entries?
[16:57:52] <jParkton> nvm found it
[17:00:29] <Nodex> find();
[17:00:44] <Nodex> and you don't need to switch collections only databases
[17:05:21] <jParkton> it is a bit different but I think I will grow to like it
[17:06:03] <Nodex> takes a little getting used to at first but in general it's the most efficient way of working in a terminal I find
[17:09:32] <belak> What's the status on this? https://jira.mongodb.org/browse/SERVER-14204
[17:09:53] <belak> I'd rather not hack around it by forcing a version of 10.9...
[17:11:33] <Nodex> Do people still dev on Macs ?
[17:11:46] <belak> Nodex: quite a few, yes...
[17:12:08] <Nodex> thought they went out with Walkmans, all the hipsters use their phones these days lol
[17:13:45] <belak> Anyway, that issue has been sitting there for a month and it's a simple one line fix, as far as I can tell.
[17:14:06] <Nodex> :/
[17:20:33] <jParkton> Nodex: I am connected to my db, and my collection but how do I render that to my page? Iknow that newb but, I have this https://gist.github.com/jparkton/79257113079072ff2172
[17:21:03] <jParkton> when I go to my /users page all I see is 'users' and not my collection, I am doing it wrong clearly but how do I correct it?
[17:25:42] <mrcni> hello
[17:27:39] <mrcni> items in my collection have two ids.. one is " "id": null," and the others look more like "_id": ObjectID("53d3130d97bd3b8c249d527e"),
[17:29:17] <mrcni> a) i don't know why this is happening. b) it's causing problems for my policies to grab the userid for authentication, users have full access to admin controls. can someone hwlp
[17:29:54] <mrcni> i'm working with sails@beta which works with node and express on windows 7 pc
[17:39:08] <Nodex> jParkton : that's down to your app
[17:41:18] <Nodex> mrcni : the _id is mongo's internal objectId
[17:41:41] <Nodex> similar to an auto increment pkey in a relational table - this is a unique identifier
[17:49:27] <mrcni> how do i remove the null id?
[17:50:33] <Nodex> loop somehting in your app and $unset it
[17:52:56] <mrcni> hmm..
[17:52:58] <mrcni> thanks
[18:02:07] <mrcni> would you be able to suggest why it's making this null Id field ?
[18:02:48] <mrcni> aside from that, i still can't grab the user id for comparison
[18:03:45] <kali> mrcni: show us your best attempt
[18:07:22] <mrcni> i tried console.log(User.id) and console.log(User._id) -- console returns undefined. i think it's not returning because the User.id has not been created yet. i've set these console.logs in a 'beforeCreate' action that occurs before the user is created. but then i also tried it outside of this action and it was still undefined. all of this code is in the user model.
[18:11:43] <kali> i assume this is mongoose (or any other node.js contraption). you should paste the full example somewhere so somebody with knowledge in node.js can help
[18:13:09] <mrcni> i downloaded mongodb, the framework uses waterline orm
[18:14:20] <mrcni> i'm trying to console.log the information here https://github.com/mrcn/C_Express/blob/master/api/models/User.js
[18:14:49] <mrcni> it begins on line 60, inside the beforeCreate action.
[18:15:36] <mrcni> this doesn't show all my attempts to call for the user id.
[18:23:44] <Nodex> your app is creating the id field, the only thing MOngodb will auto create is an _id
[18:32:08] <jbernier> hi I’m using Pymongo as a client. Can anyone explain how to search for and remove orhpaned DbRef records ?
[18:32:48] <jbernier> my collection searches simply return the objects they reference - not the references themselves
[18:35:01] <rafaelhbarros> jbernier: sorry?
[18:35:11] <rafaelhbarros> jbernier: can you give me more details, I can't quite understand what you want
[18:35:49] <jbernier> rafaelhbarros: sure I will paste something on gist
[18:36:29] <jbernier> rafaelhbarros: I’m using mongopersist which is a python orm wrapper of pymongo
[18:36:29] <rafaelhbarros> jbernier: by orphaned DBRef records, you mean records that reference some doc that doesnt exist anymore?
[18:36:35] <jbernier> no
[18:36:40] <jbernier> the document exists still
[18:36:41] <rafaelhbarros> argh, ODMs are evil
[18:36:56] <jbernier> but I’ve ‘moved’ it so it’s parent id has changed
[18:37:04] <jbernier> yeah it’s no biggie
[18:37:18] <jbernier> I just need to override __setitem__ in a couple places in my objects
[18:38:16] <rafaelhbarros> I'll wait for the gist
[18:38:19] <rafaelhbarros> then we can discuss that
[18:38:24] <jbernier> rafaelhbarros: coming right up
[18:39:42] <jbernier> rafaelhbarros: https://gist.github.com/minskmaz/12ad161e1c2f9a90ce9e
[18:39:59] <jbernier> this is the handler that gets passed the object
[18:40:23] <jbernier> line 10 I drill down into the pymongo collection objct
[18:40:47] <jbernier> _p_oid.id is the string of the mongo ObjectId
[18:41:43] <rafaelhbarros> what is
[18:41:46] <rafaelhbarros> implements?
[18:41:49] <rafaelhbarros> and adapts
[18:42:35] <rafaelhbarros> that looks like python but it doesn't have the semantics that I'm used to.
[18:42:38] <jParkton> https://gist.github.com/jparkton/27e68681a10ac00ead40
[18:42:55] <jParkton> my /users doesnt do what I expect, why is that?
[18:43:08] <jParkton> I expect it to pull my users from mongo and display them
[18:43:21] <jParkton> which may be the wrong room :O
[18:43:24] <jParkton> sorry
[18:43:32] <rafaelhbarros> nodejs room? =)
[18:43:55] <jParkton> heh
[18:44:09] <jParkton> maybe but then you get pushed to #npmPackage
[18:44:12] <rafaelhbarros> jbernier: sorry, I don't have time to read through that code.
[18:44:16] <jParkton> and that can be quit silent
[18:44:17] <jParkton> lol
[18:44:21] <jbernier> rafaelhbarros: this is simple pymongo stuff - i just need to remove a db by way of a refence to an object itself
[18:44:28] <rafaelhbarros> worst room that I have here is appengine
[18:44:31] <rafaelhbarros> nobody uses that thing
[18:44:33] <jbernier> do you know how to do that in pymongo ?
[18:44:35] <jParkton> lol
[18:44:57] <jParkton> remove a db db['dbName'].drop()
[18:45:04] <jParkton> I think
[18:45:33] <rafaelhbarros> your gist makes no sense to me
[18:45:46] <rafaelhbarros> if you want to delete a db, you might be doing something wrong
[18:46:21] <jbernier> rafaelhbarros: .find_one({'_id':ObjectId(str(folder._p_oid.id))})
[18:46:35] <jbernier> that’s where I’m accessing the object
[18:46:37] <rafaelhbarros> ok
[18:46:41] <rafaelhbarros> understand that
[18:46:59] <jbernier> I need to grab the id to the reference that’s there instead of the object it resolves to
[18:47:05] <rafaelhbarros> the first 9 of the 16 lines of that script make absolute no sense
[18:47:14] <jbernier> yah don’t woryy about those
[18:47:22] <jbernier> it’s just a zope subscription handler
[18:47:30] <rafaelhbarros> so you have the ID
[18:47:33] <jbernier> yes
[18:47:34] <rafaelhbarros> and you want the ref instead?
[18:47:39] <jbernier> folder._p_oid.id
[18:47:42] <rafaelhbarros> do you have the collection name?
[18:47:45] <jbernier> yep
[18:47:51] <jbernier> dm.get_collection_from_object(createObject('folder'))
[18:47:58] <jbernier> line 9
[18:48:02] <rafaelhbarros> I think
[18:48:05] <rafaelhbarros> one second
[18:48:08] <jbernier> then coll.collection gets me the pymongo colleciton
[18:48:13] <rafaelhbarros> let me start a shell here
[18:48:40] <jParkton> it looks more like psuedocode than actual code
[18:48:44] <jParkton> is that intentional
[18:48:45] <jbernier> so I know the object to which the dbref resolves but not the dbref itself
[18:49:13] <jbernier> which is right there in the old_parent.keys()
[18:49:25] <rafaelhbarros> ok
[18:49:41] <rafaelhbarros> https://gist.github.com/anonymous/0d7626af8bfe538d5cf2
[18:49:46] <rafaelhbarros> this is how you create a dbref
[18:49:55] <jbernier> ooh!
[18:49:58] <jbernier> Nize!!!
[18:50:11] <jbernier> rafaelhbarros: you rock thank you for hangin in there
[18:50:26] <rafaelhbarros> jbernier: sorry for being harsh, that confused me a lot.
[18:50:29] <rafaelhbarros> it was a pleasure
[18:50:45] <jbernier> rafaelhbarros: how do I remove that from a document
[18:50:56] <jbernier> let me past what the doc looks like
[18:51:03] <rafaelhbarros> you want to remove a field frm a document?
[18:51:07] <rafaelhbarros> like
[18:51:39] <jbernier> https://gist.github.com/minskmaz/3478c91e9c05cc998bea
[18:51:46] <jbernier> yes rafaelhbarros
[18:51:55] <rafaelhbarros> original doc: {'name':'joe', 'job':'nothing', 'ref': DBRef(...)}
[18:52:02] <rafaelhbarros> target doc: {'name':'joe', 'job':'nothing'}
[18:52:08] <jbernier> rafaelhbarros: from this doc I want to remove 53d67902dc2eb93388ea24ce
[18:53:08] <rafaelhbarros> $unset
[18:53:09] <rafaelhbarros> I believe
[18:53:46] <rafaelhbarros> like this
[18:53:49] <rafaelhbarros> maybe, try it out
[18:54:25] <jbernier> will do rafaelhbarros thanks again for the tips
[18:54:29] <rafaelhbarros> db.collection.update({}, {"$unset":{"_data.53d67902dc2eb93388ea24ce": ""}})
[18:54:42] <jbernier> shrweet
[19:04:10] <rafaelhbarros> sorry, had to leave
[19:04:14] <rafaelhbarros> jbernier: did it work?
[19:05:17] <jbernier> no but I’m working on rafaelhbarros
[19:54:58] <jbernier> https://editor.ponyorm.com/user/minskmaz/test
[19:55:04] <jbernier> wrong window sorry
[20:17:10] <saml> how can i plz
[20:17:11] <saml> oops
[20:49:40] <mp_> i've collected event data similar to mixpanel/google analytics in a mongodb instance & am curious about best practices for using that data in a parallel SQL DB with a django application. For example, say I want to sort a table in postgres by an aggregation from a mongodb collection. If I can, I'd like to make clean-looking queries using the Django ORM with as clean of an interface to MongoDB as possible. Any thoughts about approachin
[21:00:03] <kali> mp_: first, use a smarter irc client. either that, or make shorter lines
[21:04:34] <jParkton> !helpful
[21:29:44] <MacWinner> when running a replicaset with 2 nodes, do you need to have some sort of 3rd node up to help prevent split brain situations?
[21:43:22] <ranman> MacWinner: typically a replicaset has 3 nodes
[21:43:41] <ranman> MacWinner: you'll need to run with at least 2 and 1 arbiter for master election purposes
[21:43:56] <ranman> the docs here have lots of awesome pictures that explain it better than I could: http://docs.mongodb.org/manual/core/replication-introduction/
[21:53:07] <MacWinner> ranman, thanks! almost done setting it up
[23:23:09] <Asterfield> Is there no way to get 3 random records from a collection?
[23:24:51] <AlexZanf> hey guys I have a user model, and i am trying to add profile images to users. Should i just add a images[int,int] list to the user model? with the first param being the image slot, and the 2nd param being the image name or id? or should i make a new image model and compose with it?
[23:25:17] <Asterfield> Why not an array of filepaths?
[23:46:04] <AlexZanf> Asterfield, what do you mean?
[23:48:20] <Asterfield> AlexZanf: Add an array to the user model. http://pastebin.com/UkEiWbYv
[23:49:29] <AlexZanf> Aster, thats basically what i have, eexcept i have a slot number too, but i guess that could just be the index
[23:50:10] <AlexZanf> and i will use ints instead of strings
[23:50:15] <AlexZanf> for the image names/id's