PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Thursday the 25th of July, 2013

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:01:02] <LoneSoldier728> me love u long time
[00:01:03] <LoneSoldier728> http://stackoverflow.com/questions/17846822/how-to-get-objectid-from-another-mongoose-schema
[00:01:05] <LoneSoldier728> : )
[00:01:43] <caitp> what's the question? i can't really guess from the url
[00:02:01] <LoneSoldier728> Basically I am creating the new mongoose schema but I want to take the userId
[00:02:08] <LoneSoldier728> from the User Schema
[00:02:20] <caitp> by default, the primary key (which by default is an ObjectId) is in field '_id'
[00:02:22] <LoneSoldier728> and the userId is being created automatically on mongodb's side
[00:02:44] <LoneSoldier728> right, but how do I set a new primary key for the new schema aka collections
[00:03:10] <LoneSoldier728> to include the _id from the other schema aka other collection (users)
[00:03:20] <caitp> you mean treat it like a foreign key?
[00:04:04] <LoneSoldier728> ya
[00:04:32] <caitp> you can simply have an indexed field called userId, and make it refer to the User schema
[00:04:48] <LoneSoldier728> how do i refer it to the user schema
[00:04:56] <LoneSoldier728> that's the part im confused about
[00:04:58] <caitp> {type:ObjectId, ref: "UserOrWhatever", index: true, unique: true}
[00:05:22] <LoneSoldier728> is the " " the schema name? after the ref:
[00:05:41] <caitp> the model name i think, but those should be the same
[00:05:51] <LoneSoldier728> right
[00:06:59] <caitp> you could also just use userId as your primary key and not use an _id field
[00:07:04] <caitp> idk if that's really a good idea
[00:07:14] <caitp> probably better to just make userId a virtual for _id
[00:09:12] <LoneSoldier728> ok so does this work userId: {type: ObjectId, ref: "User", index: true, unique: true }
[00:09:26] <LoneSoldier728> or what is the virtual thing you are refering to?
[00:20:17] <LoneSoldier728> var User = require('../models/user.js');
[00:20:17] <LoneSoldier728> var Friend = require('../models/user.js');
[00:20:35] <LoneSoldier728> is that possible? if I have both schema's one the user.js page
[01:20:32] <resting> i'd created an admin user with mongo --eval "db.getSiblingDB('admin').addUser( { user:'admin', pwd:'123', roles:[ 'userAdminAnyDatabase' ] } )"
[01:20:41] <resting> restarted mongod with —auth
[01:21:02] <resting> but i couldn't authenticate with mongod -u admin -p123?
[01:35:26] <LoneSoldier728> hey
[01:36:26] <LoneSoldier728> anyone know when I make a new mongoose schema how I can reference the objectID and have it created when a new user is created or how it works?
[01:36:40] <LoneSoldier728> http://stackoverflow.com/questions/17846822/how-to-get-objectid-from-another-mongoose-schema
[01:39:57] <caitp> LoneSoldier728, you could use pre or post middleware
[01:52:45] <LoneSoldier728> Ya it isn't working for some reason unless I am writing it incorrectly
[01:52:48] <LoneSoldier728> I will pasteBin it
[01:53:25] <LoneSoldier728> http://pastebin.com/V9Kw6FV7
[01:54:22] <LoneSoldier728> https://gist.github.com/anonymous/6076261
[01:54:30] <LoneSoldier728> the first one is the new Friend Schema
[01:54:49] <LoneSoldier728> the second one is the register Post that I am trying to create a new friend user account too
[01:55:10] <LoneSoldier728> but I am pretty sure I might be doing the .pre part wrong and .save wrong in the second one
[01:56:01] <caitp> well you need to call next() regardless of what happens in your code, otherwise you might end up with an endless loop
[01:56:26] <LoneSoldier728> in which, i am calling it in the schema
[01:57:09] <caitp> you're calling it conditionally
[01:58:23] <LoneSoldier728> FriendSchema.pre('save', function(next) {
[01:58:23] <LoneSoldier728> next();
[01:58:23] <LoneSoldier728> });
[01:58:23] <LoneSoldier728> that?
[02:00:08] <caitp> well I meant the 'User' middleware
[02:01:27] <LoneSoldier728> in the gist file?
[02:01:33] <LoneSoldier728> or the pastebin
[02:01:45] <LoneSoldier728> pastebin (is the mongoose file), gist (my route file)
[02:03:31] <caitp> I haven't looked at your route file, but I assume it's working -- if it's not (and assuming you're using express), you can put `app.use(express.logger())` to see requests and status codes logged in the terminal,
[02:03:54] <caitp> or express.logger('dev') for a bit cleaner/more concise output.
[02:04:07] <LoneSoldier728> ya i do see it
[02:04:12] <LoneSoldier728> i have that exactly
[02:04:26] <LoneSoldier728> I am not getting an error
[02:04:34] <LoneSoldier728> but the friend collection db is not adding the users
[02:04:35] <caitp> so you know for sure that you're getting your requests
[02:04:54] <LoneSoldier728> well it might not be saving in the friend
[02:05:04] <LoneSoldier728> can we dcc?
[02:05:28] <caitp> neh, you can PM me, but I'm a bit busy with werk
[02:06:11] <LoneSoldier728> is PM dcc chat? how do I PM?
[02:07:03] <LoneSoldier728> http://stackoverflow.com/questions/17847773/how-to-create-a-new-account-in-another-collection-through-mongoose
[02:07:11] <LoneSoldier728> I put it up as a stackoverflow question
[02:08:03] <maslowbeer> hello. hitting my head against the wall with slaveOK=false messages even though the connection URI has in the options slaveOk is true. Noted in docs that rs.slaveoK must be run on primary "once per session" what constitutes a "session" in this context/
[02:10:07] <maslowbeer> how do I set slaveOK permanently on all my mongo nodes? running as a service
[02:22:18] <LoneSoldier728> http://stackoverflow.com/questions/17847773/how-to-create-a-new-account-in-another-collection-through-mongoose anyone?
[02:35:50] <LoneSoldier728> http://stackoverflow.com/questions/17847773/how-to-create-a-new-account-in-another-collection-through-mongoose
[02:35:57] <LoneSoldier728> Anyone know what is the deal
[03:01:06] <LoneSoldier728> http://stackoverflow.com/questions/17847773/how-to-create-a-new-account-in-another-collection-through-mongoose
[03:01:16] <LoneSoldier728> Anyone know why it goes to error on saving the second file
[03:01:28] <LoneSoldier728> saving a new account to Friends collection
[03:14:46] <caitp> okay, so this is not working
[03:15:02] <caitp> do I need to define my own way of representing times without dates?
[03:15:07] <caitp> cry :(
[03:18:17] <LoneSoldier728> I am crying because an account is not being created in my second collection : /
[03:23:26] <gx> i'm having trouble here- I have one server instance running mongodb, and i'm trying to connect to it from another server through codeigniter
[03:23:54] <gx> i've allowed port 27017 through iptables on both servers... i can connect to the db remotely using MongoVue for windows, but on the 2nd server, the connection times out
[04:32:14] <LoneSoldier728> http://stackoverflow.com/questions/17847773/how-to-create-a-new-account-in-another-collection-through-mongoose anyone?
[04:32:57] <LoneSoldier728> for some reason the account in the other collection is not being created?
[04:53:01] <jtomasrl> how can i get all matching subdocuments?
[04:54:34] <LoneSoldier728> figured it out yes love it
[04:56:31] <rickharrison> In Mongoose, on a findAndModify command, is there a way to find out if a document was inserted *and* get the new document back
[04:56:31] <rickharrison> I could set new to false, but then I don't get the document back
[04:59:03] <LoneSoldier728> $addToSet in mongoose
[04:59:13] <LoneSoldier728> lets you insert a file only if it hasnt been inserted
[04:59:29] <LoneSoldier728> so this way you do not have duplicates
[04:59:34] <LoneSoldier728> is that what you are trying to do?
[04:59:36] <rickharrison> I just want to find out if a document was inserted or updated
[04:59:51] <rickharrison> so I'm setting upsert: true in my findAndModify command
[05:00:13] <LoneSoldier728> who is modifying the doc
[05:00:26] <rickharrison> a mongoose model
[05:00:27] <LoneSoldier728> can't you query it and put a trigger if it gets updated?
[05:00:50] <LoneSoldier728> make a PasteBin
[05:00:52] <LoneSoldier728> with your code
[05:00:56] <LoneSoldier728> or a gist
[05:01:44] <rickharrison> http://pastebin.com/vPyBznqZ
[05:03:32] <LoneSoldier728> an upsert adds the document
[05:03:38] <rickharrison> Right
[05:03:39] <LoneSoldier728> if it does not exist correct?
[05:03:44] <rickharrison> Yes
[05:04:25] <LoneSoldier728> ok so your code right now is taking the user id, and then where is user coming from
[05:05:00] <LoneSoldier728> and the doc in your function should store the information from what was queried
[05:05:16] <LoneSoldier728> so idk where user is coming from but what does console.log(doc) print out
[05:05:39] <rickharrison> It prints out the user information that has like 8 properties
[05:05:53] <rickharrison> an instance of the UserModel
[05:06:30] <rickharrison> http://pastebin.com/1wkstzbq
[05:07:02] <rickharrison> I jsut want to know if a new user was created, or if it was just updated
[05:10:31] <LoneSoldier728> can you show me what was printed out
[05:10:37] <LoneSoldier728> in another pastebin
[05:10:39] <LoneSoldier728> or update it
[05:11:39] <rickharrison> Whats printed out is that same user object just with an _id as well
[05:13:05] <LoneSoldier728> what id printed
[05:13:53] <LoneSoldier728> the problem with your code is simple you are querying the update on it
[05:14:41] <LoneSoldier728> if you want to query it before it is being updated and then query it after calling update on it you can see if it was updated
[05:14:52] <LoneSoldier728> or you can write another field that is a number
[05:14:56] <LoneSoldier728> and is set to 0
[05:15:04] <LoneSoldier728> and if the doc is updated, always change it to 1
[05:15:06] <LoneSoldier728> or something
[05:15:54] <LoneSoldier728> but I am still unclear as to what you are doing honestly... you want to know if something was inserted as oppose to updated can you explain a real life situation so I can understand you better
[05:16:15] <LoneSoldier728> You can see if something was inserted as well by just noticing if the count changed for the amount of users in your collection
[05:16:27] <rickharrison> Here is what I want to do
[05:16:27] <rickharrison> I want to insert or update a user and return that document
[05:16:27] <rickharrison> And I want to find out if it was inserted, or just updated
[05:16:40] <LoneSoldier728> ok so just do .count()
[05:16:56] <LoneSoldier728> and see if it changed, if it changes then it was inserted, if it was updated the count should be the same
[05:17:14] <LoneSoldier728> if you want to see what was added just console.log(doc) or the query
[05:17:33] <LoneSoldier728> if you want to see the original info before it was updated call a query on it first without the update
[05:17:39] <LoneSoldier728> make sense?
[05:22:55] <resting> there is no role that could do a show dbs in mongo shell?
[06:39:44] <kevino> when you stop the mongo service via an init script, it doesn't shut down cleanly?
[06:39:50] <kevino> like when i restart, it's applying the journals
[06:40:10] <kevino> is there a way to make sure that won't happen? like completely flush everything to the data file and not journals?
[06:40:15] <kevino> not sure if i am explaining myself correctly
[06:51:15] <kevino> can an fsynclock'd secondary be elected primary?
[07:37:20] <[AD]Turbo> ciao
[08:44:30] <avner> First visit. hi, would that be a good place to seek for help regarding NodeJS and mongo behavior?
[08:47:18] <Nodex> best to just ask your question
[08:50:34] <avner> 10x. Trying to upsert a document and than update it's sub documents in the call back. I create a gist of how it works: https://gist.github.com/AvnerCohen/6077932
[08:51:04] <avner> I'm trying to understand why the first example does not work as expected. only the last document exists, even though i use {$set}.
[08:52:49] <kali> gosh, i hate node.
[08:54:00] <avner> 10x :) that's one direction to try out.
[08:57:52] <Nodex> collection.update({conv_hash: '711_34401'}, base_doc, {upsert: true }, function() {
[08:58:04] <Nodex> that makes no sense as the doc already exists so there is no need to upsert it
[08:59:08] <Nodex> there is also a flag called $setOnInsert which might help you
[09:00:41] <Nodex> you also don't need to do multiple $set statements.... one will suffice ... db.foo.update({},{$set:{'foo':1,'bar':2,'baz':3}})
[09:01:07] <avner> 10x. I understand it makes no sense. however, this is just used as an an example for a much more complex code. where these are not really called in a single flow.
[09:01:40] <avner> I'm trying to understand why one example works and the other not, I'm not looking for improvements for the code itself as this is just a sample.
[09:01:45] <avner> I'll take a look at setOnInsert thanks.
[09:04:41] <Nodex> db.bar.update({id:1},{$setOnInsert:{a:1,b:1,c:1}},{upsert:true}); yields ... { "_id" : ObjectId("51f0ea0a8e9d0cace856ca9a"), "a" : 1, "b" : 1, "c" : 1, "id" : 1 }
[11:32:49] <solars> hi there, quick question: if I have a couple of referenced objects, like Author, Post - and I want to do join like queries like All authors where a post contains 'fu' - I suppose mongodb is not the way to go, right? I guess it's better to use sql for such kind of data? (I've got a lot more objects that are cross referenced of course in real life)
[11:54:02] <remonvv> solars: MongoDB is not a relational database so you are correct that a JOIN is not possible. Things like that always require 2 seperate queries. Whether or not MongoDB is a good choice depends on how often you have to do relational things versus things MongoDB is good at.
[11:58:11] <solars> for this purpose it's needed quite often, so I think for this app we cannot use mongo but will stick to sql ..
[11:58:27] <solars> although it of course does a quite good job on other projects .. :)
[11:58:52] <remonvv> Yep, pick your tools wisely ;)
[11:59:00] <solars> exactly :)
[11:59:09] <Nodex> also remember just because it might make sense to join tables for representations it often doens't for performance
[11:59:35] <hyperb> What's the default behavior for mongoimport without --upsert? Does it update matched _id's?
[12:00:37] <remonvv> hyperb: It upserts on _id. Meaning it overwrites existing ones and adds non-existing ones.
[12:01:19] <remonvv> hyperb: Use --drop if you want a fresh import
[12:01:33] <hyperb> Hrm... I ran an import yesterday on some test data and I got a bunch of 'duplicate _id' messages. I added --upsert and everything went fine
[12:02:02] <hyperb> Basically, I ran mongoexport, ran some sed changes on the data, and wanted to reimport
[12:02:04] <remonvv> hyperb: Ah, I misunderstood your question. If you remove it completely it will skip existing ones.
[12:02:16] <remonvv> Right, use --upsert for that scenario.
[12:02:48] <remonvv> Or use --upsertFields if you want to upsert on more than just _id
[12:03:00] <hyperb> In my scenario, there shouldn't be any unmatched _id's. But is there a way to --update?
[12:03:08] <hyperb> I didn't see that param
[12:03:21] <remonvv> --upsertFields a,b,c is basically equiv to update({_id, a, b, c}, {...}, true, false)
[12:03:35] <solars> Nodex, yep, I'm already having a look at this, thanks
[12:03:45] <remonvv> hyperb: Isn't --upsert exactly what you need then?
[12:04:02] <hyperb> In my scenario, yes.
[12:04:29] <remonvv> hyperb: Alright. So yes, without --upsert it'll skip documents with matching _id values.
[12:04:56] <remonvv> hyperb: Also not that in some cases mongoimport/export is a bit risky
[12:05:04] <hyperb> I had conjured up a hypothetical scenario though, where I had run mongoexport from live data, then I wanted to import it on top of older test data, but only updating witout insert
[12:05:34] <remonvv> I don't think that case is supported
[12:05:40] <remonvv> You mean update if exists, do nothing if new right?
[12:05:45] <hyperb> Right.
[12:06:03] <Nodex> you'll have to parse that yourself unfortunately
[12:06:11] <hyperb> No big deal, I was just curious.
[12:06:20] <hyperb> remonvv: So what's this about risky?
[12:06:27] <remonvv> hyperb: Don't think that is supported. To be fair it doesn't make a huge amount of sense. That scenario is only relevant if you removed data from the live environment that still exists in the exported data.
[12:06:59] <remonvv> hyperb: It can't always guarantee type information. It's rather like doing something like db.col.save(db.col.find().next()) in the shell
[12:07:14] <remonvv> it could, for example, save an integer value as a real number, and so forth.
[12:07:26] <remonvv> mongodump/mongorestore do pure BSON dumps
[12:08:26] <hyperb> Well let me run this by you then...
[12:08:51] <hyperb> I'm using graylog2, which uses mongodb for the server configuration.
[12:09:20] <hyperb> I want to run some batch-renames on my streams.
[12:09:40] <hyperb> But there's no way to do that from the web interface (not surprisingly)
[12:09:59] <hyperb> so I ran a mongoexport, did the renames in the export file, and I'm about to run mongoimport to apply the changes.
[12:10:20] <hyperb> My tests yesterday went as expected.
[12:12:16] <hyperb> remonvv: ?
[12:18:30] <remonvv> hyperb: If your tests were successful there shouldn't be an issue. What are you renaming?
[12:19:40] <hyperb> They're called 'streams' in graylog2. Basically like a persistent search.
[12:21:27] <hyperb> I'm just changing the "title" field.
[12:22:00] <remonvv> why not just use $rename?
[12:22:31] <hyperb> Probably because I don't know anything about mongodb
[12:22:35] <remonvv> ;)
[12:22:39] <hyperb> but lots about grep|sed|awk
[12:22:48] <remonvv> http://docs.mongodb.org/manual/reference/operator/rename/
[12:23:01] <remonvv> If it's as simple as renaming a field you'll wanna go for that operator
[12:23:03] <remonvv> It's safe.
[12:23:26] <hyperb> Oh, I don't even want to $rename.
[12:23:32] <hyperb> I just want to .update()
[12:24:04] <hyperb> But I want to run regex batch operations
[12:24:41] <hyperb> Which I suppose I could write in JS and then load() to be safer
[12:25:11] <remonvv> Options options ;) If you have the option to do something with operators rather than JS or export->modify->import you should.
[12:25:35] <remonvv> If not, well, testing is everything ;)
[12:26:01] <hyperb> I don't mean major js. I don't even know much js.
[12:26:16] <hyperb> I honestly could probably just do it in the shell.
[12:26:29] <hyperb> I make everything so complicated.
[12:27:08] <hyperb> Well... I cant use regex with .find(), can I?
[12:27:42] <hyperb> looking at $regex
[12:28:19] <hyperb> Oh, and I can use slashes as well? That's cool.
[12:30:25] <hyperb> Lemme run this by the experts... ;)
[12:31:01] <hyperb> If I want to run through my 'streams' coll and for every "title" that starts with "OLD", I want to change it to "NEW"...
[12:31:49] <hyperb> db.streams.find({"title":"/^OLD/"}).update({$set:{"title":"NEW---- no, that won't work.
[12:32:28] <rspijker> so you need js
[12:33:26] <hyperb> Yeah, looks like it.
[12:38:43] <remonvv> hyperb: By the way, seems like a slightly odd operation. It's likely not an option for you but that looks like something that can use a schema improvement.
[12:39:17] <remonvv> Meaning something where the <OLD/NEW> value has its own dedicated field.
[12:39:54] <hyperb> Not really.
[12:40:01] <hyperb> It's not that serious.
[12:40:32] <hyperb> I just want to do a batch rename. It probably is slightly odd. Not something that should come up very often, I'd imagine.
[12:40:46] <remonvv> hyperb: I'll help you hope that that is true ;)
[12:41:11] <remonvv> hyperb: Anyway, probably easiest to do that directly in shell. Grab a cursor, iterate over it, apply the rename, save it, done.
[12:41:43] <hyperb> In any case, graylog is still in heavy development. Batch rename would be more of a 'spit & polish' feature.
[12:42:05] <hyperb> remonvv: Wanna help a brother out? ;)
[12:42:50] <hyperb> db.streams.find({"title":"/^OLD/"}) will give me a cursor containing the docs that match the regex, right?
[12:42:51] <remonvv> hyperb: Sure -> c = db.col.find(); while(c.hasNext()) {d = c.next(); d.title = <yourmagic>; db.col.save(d);}
[12:43:07] <remonvv> or you can forEach directly on the cursor
[12:43:09] <remonvv> whichever
[12:43:28] <remonvv> in that case db.col.find().forEach(function(d) {<same>})
[12:44:00] <remonvv> Graylog as in this http://graylog2.org/ btw?
[12:44:06] <hyperb> yes, that's graylog
[12:44:19] <remonvv> hyperb: And you're developer or user of it?
[12:44:22] <hyperb> user
[12:44:41] <hyperb> But I want to do things that I'm not allowed to. ;)
[12:44:50] <remonvv> Okay, well when you get the above sorted tell me your experiences. I'm looking at log aggregation that isn't shit.
[12:44:59] <hyperb> like batch rename. ;)
[12:45:08] <hyperb> Oh, I've rolled it into prod.
[12:45:17] <hyperb> Now my use case may be somewhat fringe.
[12:45:37] <remonvv> That describes most of my problems that I need solutions for ;)
[12:46:04] <hyperb> I'm a Linux admin supporting numerous dev environments for a major internal webapp.
[12:46:25] <hyperb> The actual developers are outside contractors.
[12:46:39] <hyperb> They need to look at their logs, but we didn't want to give them ssh access.
[12:47:16] <hyperb> My predecessor had a cron job that scp'd the scripts all to one box and some real simple php display scripts.
[12:47:21] <hyperb> But they wanted something nicer.
[12:47:40] <remonvv> THat sounds like a wonderful solution ;)
[12:47:51] <hyperb> I think most of graylog use is for http access/error logs
[12:47:58] <hyperb> I'm using it for JBoss.
[12:48:06] <hyperb> there's also logstash.
[12:48:31] <hyperb> I'm actually using the logstash client piece to format the data and send it to graylog
[12:48:58] <hyperb> but graylog is inherently multi-user. The main reason we chose it.
[12:49:38] <hyperb> My main complaint is that #graylog2 is D.E.A.D.
[12:50:12] <hyperb> Last message was 9 hours ago.
[12:50:31] <hyperb> umm... that's an irc channel, btw, not a hashtag. ;)
[12:52:01] <remonvv> I figured.
[12:53:22] <remonvv> Log aggregatopm is an underappreciated problem.
[12:53:30] <remonvv> Pretend I spelled that right.
[12:54:56] <hyperb> Yeah. Once we're running full-time, I'm gonna look at building out a cluster with queueing to aggregate everything.
[12:56:15] <hyperb> remonvv: So can you help with the <yourmagic> part? I basically just want s/old/new with substrings
[12:58:23] <hyperb> remonvv: which in js would be .replace("old","new"), right?
[13:00:12] <remonvv> hyperb: If you're sure there's only 1 occurance of "old", yes
[13:00:31] <remonvv> hyperb: I'm no JS expert. Alternatively you can try "NEW" + old.substr("OLD".length, old.length)
[13:00:53] <hyperb> in my case, there will be only one.
[13:01:09] <hyperb> What you're saying is that .replace() is like s/old/new/g
[13:04:12] <remonvv> Right, replace accepts a string or regex for the search value
[13:04:15] <remonvv> and replaces it with the new value
[13:07:42] <Nodex> foo accepts bar
[13:07:50] <hyperb> So there are no 'document' methods in mongodb?
[13:07:59] <remonvv> hyperb: Meaning?
[13:08:47] <hyperb> inside a forEach, my objects are documents. Not collections or cursors. Right?
[13:09:34] <remonvv> right, and documents in this case are ust JS objects
[13:10:07] <hyperb> Well, everything's a js object. That's one thing I dig about mongodb. :)
[13:10:48] <hyperb> This probably doesn't matter, but I'm curious.
[13:11:00] <hyperb> I'm testing out functions within forEach()
[13:11:09] <hyperb> db.streams.find().forEach(function(i) {print(i._id)})
[13:11:52] <hyperb> ...gives me a bunch of: ObjectId("hexhexhex")
[13:11:54] <Nodex> this == current document too iirc
[13:11:56] <remonvv> For you it's basically db.col.find().forEach(function(d) { d.title = d.title.replace("old", "new"); db.col.save(d);}
[13:12:00] <hyperb> I tried this.
[13:12:24] <remonvv> Yes, _id values are typicall of type ObjectId
[13:12:30] <hyperb> Nodex: this._id gave me an error
[13:12:39] <hyperb> remonvv: I'm not done, sorry... ;)
[13:13:02] <hyperb> anyway, if I add a string to the print command, like:
[13:13:13] <hyperb> db.streams.find().forEach(function(i) {print("_id: "+i._id)})
[13:13:29] <hyperb> It gets rid of the ObjectId("") container
[13:13:35] <hyperb> I get: _id: hexhexhex
[13:13:49] <Nodex> that;s because it's now been cast to a string
[13:14:00] <remonvv> Yes, it will invoke the toString() method of the object automatically due to string concatenation
[13:14:07] <hyperb> Indeed.
[13:14:10] <remonvv> Not casting technically, but yeah
[13:14:20] <hyperb> Yeah, makes total sense.
[13:14:37] <Nodex> it is casting by invariance
[13:17:54] <remonvv> Is it? In Java it's implemented as a compiler step unique to string concatenation where toString() invocations are inserted at compile time. Afaik it was the same in JS but I could be wrong. JS isn't my thing ;)
[13:18:20] <Nodex> I was making up a word LOL, seeeing if I coulld get away with the troll
[13:18:22] <Nodex> lmfao
[13:18:37] <remonvv> How often does that work out for you? ;)
[13:18:46] <Nodex> sounds kinda cool though... in the javascript quirks concatting always casts to a string
[13:19:02] <Nodex> "" + int(1) = string iirc
[13:19:02] <remonvv> Invariance is a word though ;)
[13:19:06] <remonvv> It is
[13:19:19] <remonvv> That compiles to "" + int(1).toString()
[13:19:55] <Nodex> it's intollerable regression from the former latter type model I heard
[13:20:35] <remonvv> Yes, XML CORBA pipeline commit flow is little endian too
[13:20:55] <Nodex> ron is a little endian
[13:26:31] <remonvv> I love watching marketing people from technical companies talk.
[13:27:22] <Nodex> lol
[13:27:23] <remonvv> http://www.quickmeme.com/meme/3vakem/
[13:27:50] <Nodex> I like watching cartoons talking to cheese
[13:35:34] <hyperb> ok, dumb shell question time
[13:36:03] <hyperb> When the shell displays a cursor, it looks like crap.
[13:36:12] <hyperb> When it displays a document, it looks pretty.
[13:36:23] <Derick> db.find().pretty();
[13:36:46] <hyperb> How can I display all the docs in a cursor?
[13:37:09] <rspijker> you can iterate over them with it
[13:37:19] <rspijker> alternatively, you can use js to do so...
[13:37:22] <Derick> r = db.find(); r.forEach( function( e ) { print e ....
[13:37:38] <hyperb> Right. Oh... Ican just call print on a doc? I'm an idiot.
[13:37:43] <cheeser> db.find().foreach(printJson)
[13:37:46] <Derick> no, I don't think so
[13:37:50] <Derick> printJson I think it's called
[13:38:18] <hyperb> nope
[13:38:26] <Derick> db.so.find().forEach(printjson);
[13:38:28] <Derick> worked for me
[13:38:45] <hyperb> oh, gotcha.
[13:38:48] <cheeser> bah. i always get that case wrong. :)
[13:39:28] <hyperb> beautiful. Thanks.
[13:47:23] <intellix> anyone know of a good Mongo GUI for OSX? It seems that 90% of the apps I try just do not work at all… MongoHUB seems to crash every time. Umongo doesn't work
[13:47:58] <cheeser> i'm building one but it's web based not OS X specific
[13:48:15] <remonvv> It's kinda bullshit printjson isn't camelcased.
[13:48:29] <Nodex> +2
[13:48:30] <cheeser> there's this: http://docs.mongodb.org/ecosystem/tools/administration-interfaces/
[13:48:37] <remonvv> cheeser: You're building one?
[13:49:26] <cheeser> yeah. http://www.antwerkz.com/blog/ophelia
[13:49:44] <remonvv> intellix: WHy does UMongo not work?
[13:49:52] <intellix> it opens…… then closes
[13:50:01] <intellix> will try downloading again
[13:50:15] <remonvv> intellix: Odd. Works for me. Check logs.
[13:50:25] <intellix> ah I have 1.1.1
[13:50:27] <intellix> and it seems 1.4.2 is out
[13:50:57] <intellix> I got mine from here: https://github.com/agirbal/umongo
[13:51:35] <remonvv> cheeser: Nice. Tackled the "run on the same host" thing yet?
[13:52:09] <intellix> just got this, and at least it opens now :D http://edgytech.com/umongo/
[13:52:23] <intellix> ah umongo doesn't support SSH?
[13:52:26] <remonvv> intellix: Yeah it's written by a 10gen employee iirc. Used to be JMongoBrowser or something
[13:52:50] <remonvv> intellix: Not sure. Never used it beyond having a look at it.
[13:53:40] <cheeser> remonvv: i haven't yet because i've been busy trying to fix javabot and get my javaone presentations done. but i'm angling to get back on that soon.
[13:56:06] <remonvv> cheeser: I see. Most production environments use local mongos instances so it's not a huge deal I suppose.
[13:57:08] <cheeser> right. i know that's what we did where I worked when I wrote that so it wasn't urgent.
[13:58:50] <remonvv> yeah I'm pretty sure it's the 90% case.
[13:58:53] <intellix> damn, nothing seems to work :/ the GUI scene for Mongo is pretty much dead
[13:59:20] <remonvv> intellix: Real men work in the shell.
[14:00:03] <intellix> it's such a bitch writing mongo queries in shell
[14:00:10] <intellix> it's too easy to get lost in the brackets
[14:00:16] <intellix> have I put enough? did I close them all?
[14:00:32] <cheeser> the shell highlights the matching brace/paren
[14:01:26] <intellix> it's still quite tedious with special characters :S
[14:01:56] <intellix> not being able to click to the start of a long line of text :P
[14:02:01] <cheeser> or when you need to edit a query in your history.
[14:02:11] <cheeser> i tend to build my queries in vim then paste them in.
[14:02:29] <intellix> and you don't really have an overview of your data
[14:03:14] <remonvv> If it takes you twice as long to do the result will be twice as good. It's only due to practical difficulties that I do not write code using postal pigeons.
[14:03:39] <remonvv> On a slightly more serious note; there aren't any really smooth GUIs for MongoDB that I'm aware of. I've tried quite a few.
[14:04:53] <intellix> ok
[14:05:11] <intellix> I just want to change values of 8 documents
[14:05:26] <intellix> so much easier to just scroll down a list of rows, double click, edit, double click, edit, double click, edit, save
[14:06:22] <spacemonkey> Derick: You still working on the php extension?
[14:06:43] <Derick> yeah
[14:06:46] <intellix> you can't deny that all of the parens and brackets are a complete mindfuck when writing on a single line
[14:06:49] <Derick> But I got to run, flight to catch
[14:07:08] <Derick> intellix: yeah, I wish people on StackOverflow would format nicely :-)
[14:09:43] <spacemonkey> Derick can you point me to where I can setup mongo.so as a session handler?
[14:09:49] <remonvv> intellix: Nobody's disagreeing but it takes a healthy amount of effort to make a GUI that does all that and keep it up to date with mongo's still evolving syntax/operators
[14:09:49] <spacemonkey> And have a safe flight :-)
[14:10:14] <Nodex> spacemonkey : yu probably have to do that yourself by registering a session handler
[14:10:37] <spacemonkey> The extension by default does not register itself as a valid handler candidate though.
[14:11:05] <spacemonkey> http://www.php.net/manual/en/session.configuration.php#ini.session.save-handler
[14:11:14] <Nodex> a quick google http://www.nathandavison.com/posts/view/12/php-sessions-stored-in-a-mongo-database
[14:11:41] <spacemonkey> Yeah, that's not done through the extension itself though, was just checking there as the primary source.
[14:11:44] <spacemonkey> Thanks though.
[14:12:04] <Nodex> there is no inbuilt session handler with the driver
[14:12:22] <spacemonkey> I know, that's why I'm asking, thinking about submitting a pull request.
[14:12:27] <spacemonkey> Would be totally useful.
[14:13:39] <spacemonkey> But wanted to check if someone else was already on it, to avoid duplicate effort.
[14:13:39] <hyperb> Going back to getting lost in the brackets, does the highlighting not help?
[14:16:32] <Nodex> lost brackets?
[14:42:53] <hyperb> Troubleshooting steps for a db.coll.update() that's not updating?
[14:43:51] <remonvv> hyperb: What are you trying to do and what isn't working?
[14:44:08] <remonvv> hyperb: If you're trying to update multiple documents at once make sure you pass multiple=true
[14:44:52] <hyperb> It's always something simple with me.
[14:47:39] <hyperb> That was it, thanks.
[14:48:24] <cheeser> that's a horrible default
[14:51:44] <remonvv> cheeser: We're still looking for the one person that thinks it's a good default.
[14:52:10] <cheeser> i think i know what that was so i probably shouldn't rant too much (publicly) :D
[14:52:38] <remonvv> What the reason was for that being the default?
[14:53:13] <cheeser> sorry. not what, who.
[14:53:29] <remonvv> elliot?
[14:53:31] <cheeser> that "what" was, i think, the principal of least surprise
[14:53:56] <cheeser> that and collections can grow to be *quite* large and when sharded, updating everything that matches can be quite expensive.
[14:54:15] <cheeser> so it makes a bit of sense but usually ends up biting people in the ass because they expect the other behavior.
[14:54:15] <remonvv> cheeser: Yes but that's not an excuse for a bad default though. Too large -> optimize
[14:54:38] <cheeser> that trivializes the complexities involved, though.
[14:54:46] <cheeser> it's not quite as simple as "optimize"
[14:55:08] <remonvv> It really is. If you find yourself in a situation where a multi-update takes too much time then that's something you'll have to solve.
[14:55:27] <remonvv> I think it has little bearing on whether or not the default should be the unexpected but faster approach.
[14:55:40] <remonvv> It's similar to the safe writes not being the default until 2.0 discussion.
[14:55:42] <cheeser> well, clearly someone thought otherwise.
[14:55:59] <remonvv> I think it was an honest mistake at some point and they failed to correct it prior to 0.9
[14:56:22] <remonvv> And now everyone agrees it's a bad default (including the original authors) but it's a backward compatibility issue now.
[14:59:39] <remonvv> https://jira.mongodb.org/browse/SERVER-1690
[15:02:30] <hyperb> next weird question: reordering documents in a collection.
[15:03:13] <remonvv> hyperb: collections are not ordered.
[15:03:20] <hyperb> $natural
[15:03:21] <remonvv> hyperb: You'll have to sort in your query
[15:03:51] <remonvv> hyperb: Okay, let me rephrase; collections are naturally ordered and it's not easy to manipulate natural ordering reliably.
[15:04:16] <hyperb> Understood.
[15:04:32] <remonvv> hyperb: It's best to use .sort(..)
[15:04:54] <remonvv> hyperb: Only collection type where natural ordering is somewhat relevant is capped collections.
[15:05:20] <hyperb> I know it's best to use .sort()
[15:05:31] <remonvv> hyperb: Okay, what are you trying to do?
[15:05:35] <hyperb> But I'm db-hacking on an app I'm not developing
[15:05:52] <hyperb> stream categories are displayed in $natural order.
[15:06:01] <hyperb> I just renamed my top one, and now it's at the bottom
[15:09:13] <aquarius> http://docs.mongodb.org/manual/core/document/#timestamps suggests that timestamps in the oplog are a 64 bit number where the first 32 bits are seconds since the epoch. When I query mongo from code, I get weird values back, like: "ts": "5904541388648742913". What's that? (I can't test in the shell, because the shell knows about Timestamp types and automatically decodes...)
[15:10:34] <kali> aquarius: what language/driver are your working with ?
[15:10:44] <aquarius> kali, node and mongoose.
[15:22:24] <aquarius> aaah, I have worked it out; it stringifies weirdly. Got it.
[15:28:31] <LoneSoldier728> ok quick question
[15:28:43] <double_p> timeout
[15:28:52] <LoneSoldier728> if I have two separate arrays one that holds the friend id and another that holds the date it was received on
[15:29:02] <LoneSoldier728> how do I go about removing the date after I remove the friend
[15:29:16] <LoneSoldier728> they are in the same spots in the arrays [x]
[15:29:31] <LoneSoldier728> but how do I call it on a $pull
[15:30:38] <Nodex> good question
[15:30:50] <LoneSoldier728> any good answers lol
[15:32:02] <Nodex> it will involve the $ postional operator, not sure how you use that on an index key
[15:32:05] <Nodex> array key*
[15:32:53] <LoneSoldier728> right I cannot use that in mongoose anyways
[15:33:09] <LoneSoldier728> is it worth doing another query for it? or storing the id with the date in the array for date
[15:33:10] <Nodex> how come?
[15:33:49] <Nodex> I would re-model the data tbh and store the _id, timestamp, name etc of the friend and pluck that whole thing from the array
[15:33:50] <LoneSoldier728> positional operators do not work in mongoose from what I read at least... I just reshaped my whole db because of it actually (adding a second collections for friendships
[15:34:01] <bbommarito> Good morning/afternoon all. I have a quick question: Is it possible that using something other than an ObjectID as the _id for a document to cause a huge slow down in read/write time on a given document?
[15:34:07] <Nodex> mongoose is the dumbest thing on the planet then
[15:34:29] <Nodex> bbommarito : no but index bound updates / inserts might
[15:34:46] <Nodex> plus on large write loads mongo decreases in performance over time
[15:35:18] <LoneSoldier728> I originally did what you said Nodex
[15:35:25] <LoneSoldier728> but then when it came to the $pull part
[15:35:32] <LoneSoldier728> I could not pull an array from the array
[15:35:38] <LoneSoldier728> and it became this whole big deal
[15:35:47] <LoneSoldier728> that is why I separated it all into an array
[15:35:51] <bbommarito> Nodex: Okay, that's the answer I needed. I am working for a startup using MongoDB as a backend, and our outsourced team has basically rebuilt 30% of the app to replace our current _id structure with ObjectID, claiming it was the cause of slowdown (It's not, it's bad code).
[15:36:29] <LoneSoldier728> ObjectID's are smaller in size
[15:36:31] <Nodex> LoneSoldier728 : you can do it in 2 queries I imagine... first query to update the array member setting somehting to 1 (deleted:1) .... second query to $pull all foo.deleted:1
[15:36:34] <LoneSoldier728> from what I understand tho
[15:36:39] <LoneSoldier728> bbommarito
[15:37:01] <Nodex> bbommarito : when you use ObjectId you get a free index
[15:37:06] <Nodex> and a free sort() :)
[15:37:18] <LoneSoldier728> Yeah I imagined that is a waste though right to do both queries? Does mongo timestamp when things are added to the document anyways?
[15:37:47] <Nodex> LoneSoldier728 : you don't need to do the delete query every time, you can do it once a day or w/e
[15:38:33] <LoneSoldier728> well if a friendship needs to be removed I would want to delete it right away
[15:38:47] <drag> Hi there. How do you delete with MongoOperations? It doesn't seem to have a delete() method anymore. Is it find and remove now?
[15:39:03] <drag> *findAndRemove()
[15:39:09] <Nodex> remove()
[15:40:41] <drag> Nodex, would a findAndRemove be safer than a simple remove()?
[15:41:02] <Nodex> sorry, I didn't see the "MongoOperations"
[15:41:05] <Nodex> is that some driver?
[15:41:34] <drag> It's spring data mongo. It has both remove and findAndRemove
[15:41:58] <Nodex> perhaps findAndRemove finds it, removes it and returns it in one operation
[15:42:24] <bbommarito> Nodex: Well, I appreciate the help.
[15:42:32] <drag> thanks, Nodex.
[15:42:36] <Nodex> bbommarito : shoot the dev in the face :)
[15:42:45] <LoneSoldier728> lol
[15:42:52] <bbommarito> Nodex: 5 days...5 days...that's all we have to deal with them for.
[15:43:11] <Nodex> are they of eastern descent?
[15:43:38] <bbommarito> Nodex: They come from a country that...is a part of the Bible, and I will go no further
[15:44:17] <Nodex> haha
[15:45:07] <LoneSoldier728> Nodex any clue how I can loop through to find a position in the array does something like this work find(users) then loop and state the array position for the user
[15:45:14] <LoneSoldier728> no that has to be stupid
[15:45:21] <LoneSoldier728> if there are a lot of users no?
[15:45:32] <Nodex> you will have to loop the array yourself and remove the element and put it back
[15:46:08] <LoneSoldier728> right
[15:46:25] <LoneSoldier728> but that will take forever no?
[15:46:33] <LoneSoldier728> if there is like 10k users lets say
[15:46:36] <Nodex> depends how big the array is
[15:46:50] <Nodex> you're only looping 1 persons friends list no?
[15:46:58] <LoneSoldier728> oh right
[15:47:04] <LoneSoldier728> lol
[15:47:23] <LoneSoldier728> so if I did a find query on all his requests or friends
[15:48:03] <Nodex> tbh mongo is not really suited for what you're trying to do
[15:48:06] <LoneSoldier728> then how do I figure out the array, like I know I can loop through for the user or, do I just figure out what i equals at that point
[15:48:07] <LoneSoldier728> got it
[15:48:18] <Nodex> it's really the job of a graph db
[15:50:15] <LoneSoldier728> yeah nobody got time for a graph db
[15:50:34] <LoneSoldier728> im trying to make a small social networking site
[15:50:45] <Nodex> you're gonna have to make do with what you can then. tbh if Mongoose cannot do positional operator you should get rid of it
[15:50:54] <LoneSoldier728> small meaning for learning purposes but thinking of scalability along the way
[15:51:32] <remonvv> scalable graphs such as friend networks are...and here comes the understatement of the day...tricky.
[15:51:34] <Nodex> I wrote a large Adult networking site with MongoDB, friends was a problem, I ended up using redis to store them and when they're online etc
[15:51:51] <Nodex> wrote / built
[15:52:10] <remonvv> Nodex, so you're responsible for redtube.com huh
[15:52:15] <LoneSoldier728> lol
[15:52:21] <Nodex> I wish, I would be richer than I am
[15:52:29] <Nodex> wouldn't have to work so hard LOL
[15:52:33] <LoneSoldier728> I am a proud member of youjizz
[15:52:45] <remonvv> I have the feeling we're straying OT here.
[15:52:49] <LoneSoldier728> ya
[15:52:52] <LoneSoldier728> so
[15:53:04] <LoneSoldier728> I think mongoose actually lets you maybe do positional not sure
[15:53:10] <LoneSoldier728> can't find it in there documentation
[15:53:31] <remonvv> LoneSoldier728: In one sentence what is it you're trying to do?
[15:53:37] <Nodex> it should do else it's dumber than David Cameron
[15:54:17] <LoneSoldier728> I am trying to remove a date_added from the date_added array when removing a friendId from the friend Array ( so two diff arrays with the same position in each)
[15:54:44] <remonvv> Why isn't that on array with {friendId:.., date_added:...}?
[15:54:53] <LoneSoldier728> The reason I have two arrays because there tends to be problems with $pull / remove when there is an array in an array
[15:55:10] <remonvv> I'm...confused. Why would there be nested arrays?
[15:55:32] <remonvv> And yeah, there are. As a general rule never do nested arrays until they fix the multi-$
[15:55:44] <Nodex> you can pull array in array because the second array is only really an object
[15:55:52] <Nodex> you need the positional operator though
[15:55:54] <remonvv> yah, it's messy
[15:56:16] <LoneSoldier728> if I had friend as an array {x, y,z}
[15:56:17] <remonvv> but why isn't your schema (roughly) db.users{friends:[{friendId:.., dateAdded:..}, {..}]}
[15:56:27] <LoneSoldier728> and then x is a,b,c
[15:56:31] <LoneSoldier728> that is two arrays no?
[15:56:32] <Nodex> ^^ that's how the schema should be
[15:56:43] <Nodex> that's an object inside an array
[15:56:47] <Nodex> array = [] ... object = {}
[15:56:51] <remonvv> LoneSoldier728: No, you have a single top level array with objects as elements.
[15:57:00] <remonvv> Right, what he said
[15:57:10] <LoneSoldier728> Ok, idk that is what I did originally
[15:57:19] <LoneSoldier728> but was having trouble doing a $pull or $unset
[15:57:29] <remonvv> Most people have issues with that. Look at $elemMatch
[15:57:33] <remonvv> But that's the right schema.
[15:58:03] <LoneSoldier728> why is mongoose documents so shitly put
[15:58:40] <cheeser> it *is* opensource. i'm sure updates would be welcome. :)
[15:58:41] <remonvv> LoneSoldier728: We can only speculate.
[15:58:46] <LoneSoldier728> The way you have it writter remonvv
[15:58:51] <Nodex> db.foo.update({"_id":ObjectId("..."),"friends.friendId":1},{$pull:{friends.$:1}});
[15:58:54] <LoneSoldier728> How would you go about removing an id after
[15:58:55] <Nodex> or somehting to that effect
[15:59:11] <Nodex> where friends.friendId=1
[15:59:42] <LoneSoldier728> without the positional operator because idk mongoose deal with that
[15:59:49] <LoneSoldier728> no where in there docs
[16:00:24] <remonvv> LoneSoldier728: update({..}, {$pull:{friends:{$elemMatch:{friendId:<yourId>}}})
[16:00:35] <remonvv> Can skip elemMatch if you can afford exact matching
[16:00:38] <Nodex> or that^
[16:00:44] <Derick> pull with elemmatch makes no sense
[16:00:49] <Derick> pull pulls vull array values
[16:00:56] <Derick> elemMatch plays no role there
[16:01:01] <Derick> vull->full
[16:01:20] <LoneSoldier728> would pull remove the whole object containing the id, request date, etc?
[16:01:40] <Derick> LoneSoldier728: no, you need to give it the full array value - if it's an object, it wants all keys
[16:01:42] <Nodex> apparently mongoose supports positional
[16:02:29] <LoneSoldier728> $pull :{friends: {friendId: sddfs32s}
[16:02:33] <LoneSoldier728> that should work right?
[16:02:54] <Nodex> no
[16:03:05] <remonvv> Derick: I brainfarted, but it does not require the full object either
[16:03:06] <Nodex> in any case it would be friends.friendId
[16:03:16] <LoneSoldier728> yeah that always gave me errors
[16:03:18] <LoneSoldier728> Nodex
[16:03:20] <LoneSoldier728> the period
[16:03:21] <Derick> remonvv: are you sure? :-)
[16:03:28] <remonvv> Derick: Pretty sure ;)
[16:03:31] <Nodex> try "friends.friendId"
[16:03:35] <Derick> try it :P
[16:03:35] <Nodex> (quotes)
[16:03:41] <LoneSoldier728> I did that does not work Nodex
[16:03:46] <LoneSoldier728> that was my major problem
[16:03:49] <LoneSoldier728> the period
[16:04:00] <LoneSoldier728> and I tried friends.$.friendId
[16:04:01] <Nodex> then Mongoose is totaly retarded
[16:04:03] <LoneSoldier728> had problems too
[16:04:15] <Derick> that's right, the . wouldn't work
[16:04:23] <Derick> pull only pulls objects of an array
[16:04:55] <remonvv> Derick: http://pastebin.com/pE5Gt9b4
[16:05:11] <LoneSoldier728> let me gist my code and just show you what I am doing and then lets see the critique
[16:05:32] <Derick> remonvv: ok, settled
[16:05:34] <Nodex> remonvv : I think he was reffering to $elemMatch
[16:05:39] <remonvv> He was.
[16:05:39] <Derick> no
[16:05:45] <remonvv> Well, that was just me being an idiot ;)
[16:05:47] <Derick> Nodex: I wasn't
[16:06:03] <LoneSoldier728> https://gist.github.com/anonymous/6081228
[16:06:20] <remonvv> I had the inconsistent syntax discussion so often in here I jumped on the wrong side of the "correct" line on that one :p
[16:06:23] <Nodex> Derick : sorry, I re-read - it wasn't you that said it, you re-pasted LOL
[16:06:27] <LoneSoldier728> ok so that includes the new schema I made for friends, I actually want to set the userId as the objectId I have yet to do that
[16:06:44] <LoneSoldier728> and the code for accepting a contact should be adding a person to friends while removing them from requests
[16:06:57] <Derick> :P
[16:07:57] <remonvv> Derick: I think I once argued that $elemMatch should be part of $pull syntax rather than it being implied and that an $pull without it should do exact object matching.
[16:08:02] <remonvv> Which would be more consistent.
[16:08:19] <LoneSoldier728> Any critique lol?
[16:08:31] <remonvv> LoneSoldier728: _id == UUID is ok, usually
[16:08:33] <Derick> remonvv: I don't disagree
[16:08:33] <Nodex> I once argued that brown was the new orange
[16:08:44] <cheeser> orange is the new black
[16:08:50] <remonvv> Amazing show
[16:08:54] <Nodex> thats where I was wrong
[16:08:57] <remonvv> Captain Janeway in jail.
[16:09:06] <Nodex> trekkie
[16:09:19] <Derick> i need to get on my flight, see y'all later
[16:09:25] <Nodex> anyone watch "Sons of ANarchy" ?
[16:09:30] <Nodex> safe flight
[16:09:31] <remonvv> LoneSoldier728: You can't do the second step in one go unless you have the pending requests array in the same document
[16:09:34] <LoneSoldier728> oh remonv if I change userId to _id
[16:09:38] <remonvv> Nodex: Religiously
[16:09:44] <LoneSoldier728> and it should set it?
[16:09:57] <Nodex> I just started watching it remonvv.. I've watched 4 seasons in 1 week LOL
[16:10:04] <remonvv> LoneSoldier728: Can't. A mapper might allow you to map it from and to _id but _id is a mandatory field in a document
[16:10:16] <remonvv> Nodex: Good man.
[16:10:18] <Nodex> I stay up most the night watching LOL
[16:10:31] <LoneSoldier728> remonv I have the request being sent in another add contact post
[16:10:36] <LoneSoldier728> if that is what you are getting at
[16:11:26] <remonvv> LoneSoldier728: I mean that removing a pending friend request and adding a friend to the friends array in the user document can only happen in a single update if the pending friends requests array is in your user document. Which isn't a terribly bad idea mind you.
[16:11:52] <remonvv> The add request would simply add an entry to the pending friends request array of the invitee
[16:12:48] <LoneSoldier728> I have both in the Friend's schema and I am adding to set the new friends id while removing the id from the requests
[16:12:52] <LoneSoldier728> at the same time
[16:13:00] <LoneSoldier728> does that make sense?
[16:13:35] <LoneSoldier728> I have a received request and pending request so this way I can show recieved requests in notifications
[16:13:46] <LoneSoldier728> and pending requests cannot be added again in search results
[16:14:05] <LoneSoldier728> and this way they are attached to the users that are performing the actions
[16:14:33] <LoneSoldier728> the only thing I am having a problem with is the date's associated with the actions
[16:15:02] <LoneSoldier728> I was actually wondering if mongo already has timestamps built in so I do not even have to collect that data
[16:15:11] <LoneSoldier728> does it?
[16:20:14] <remonvv> LoneSoldier728: Not in a way you should count on but ObjectId's have a timestamp element.
[16:20:40] <remonvv> new ObjectId().getTimestamp()
[16:20:49] <remonvv> it's UTC, 1 second accuracy.
[16:21:13] <LoneSoldier728> the only accuracy I might need is the day
[16:21:22] <LoneSoldier728> it being off by seconds doesnt matter
[16:21:28] <remonvv> I'd just store a date or timestamp
[16:21:58] <LoneSoldier728> So any suggestions on the removal of the time stamps then
[16:22:05] <LoneSoldier728> with the way my file looks?
[16:22:17] <ron> remonvv: the fact that you use babypink as a color is alarming.
[16:22:41] <remonvv> Store a timestamp field, and use it. It's not very complicated unless I misunderstand your requirement.
[16:22:55] <remonvv> ron: It's my favorite color. Name one thing that's babypink and bad.
[16:23:18] <ron> remonvv: sure. babypink.
[16:23:24] <LoneSoldier728> well you see how I have it separated from the id array
[16:23:30] <remonvv> +b ron
[16:23:46] <LoneSoldier728> so I would have to remove it based on the array position
[16:23:49] <remonvv> I can't magically look into your schema design kind sir ;) Pastebin it?
[16:23:57] <LoneSoldier728> https://gist.github.com/anonymous/6081228
[16:24:02] <LoneSoldier728> i reached my pastebin limit
[16:24:03] <remonvv> It would/should be part of the array element
[16:24:04] <LoneSoldier728> so gist work?
[16:24:05] <LoneSoldier728> lol
[16:24:11] <ron> remonvv: you love me.
[16:24:13] <remonvv> Whatever works
[16:24:19] <remonvv> ron: In every single way you can imagine
[16:24:27] <ron> eew.
[16:24:28] <LoneSoldier728> https://gist.github.com/anonymous/6081228
[16:24:35] <ron> remonvv: I need a job. wanna hire me?
[16:24:36] <remonvv> ron: You play around with that mental image for a bit.
[16:24:46] <remonvv> ron: I don't mix business and pleasure.
[16:24:52] <LoneSoldier728> smart man
[16:25:10] <LoneSoldier728> a wise owl once said
[16:25:12] <LoneSoldier728> who
[16:25:26] <ron> remonvv: I don't care. hire me.
[16:25:35] <remonvv> LoneSoldier728: Basically wrap all your seperate arrays into one and each array element should contain all those fields (so dateRequested, dateReceived, friendId, and so on}
[16:25:38] <ron> come on. part time job. just to help me get started.
[16:25:49] <remonvv> ron: Started doing what?
[16:25:56] <LoneSoldier728> but then how do I remove it
[16:25:59] <LoneSoldier728> that was the hard part
[16:26:11] <remonvv> LoneSoldier728: $pull?
[16:26:22] <ron> remonvv: my personal project, man. you know what.
[16:26:23] <LoneSoldier728> it was not working
[16:26:25] <LoneSoldier728> let me try
[16:26:32] <LoneSoldier728> actually see if it is different at all
[16:26:58] <LoneSoldier728> can i specify the elements in mongoose?
[16:26:59] <remonvv> ron: Why should I hire you to get your personal project started. It's a pretty good idea. Go for it ;)
[16:27:23] <remonvv> LoneSoldier728: Yes, you can use array position in your query. So friends.1.friendId
[16:27:52] <ron> remonvv: because I need money. hence, part time.
[16:28:51] <remonvv> ron: So your plan is to ask an e-buddy on the other side of the world to ask for a part time job huh ;)
[16:29:10] <LoneSoldier728> but that does not work in mongoose
[16:29:14] <LoneSoldier728> for some reason?
[16:29:25] <remonvv> LoneSoldier728: I don't use mongoose. Can't help you there.
[16:29:28] <LoneSoldier728> the period errors
[16:29:39] <remonvv> LoneSoldier728: Did you quote the thing?
[16:29:41] <LoneSoldier728> am I allowed to use regular mongo query with mongoose
[16:29:45] <LoneSoldier728> ya i did
[16:29:48] <ron> remonvv: sure.
[16:30:00] <LoneSoldier728> or is the schema built strictly with mongoose
[16:30:06] <remonvv> LoneSoldier728: Again, I don't use mongoose ;)
[16:30:07] <LoneSoldier728> so using mongo wouldnt work
[16:30:12] <LoneSoldier728> aha damn
[16:30:23] <LoneSoldier728> Have you ever used two diff methods of querying tho
[16:30:30] <LoneSoldier728> one through a module or another way
[16:30:33] <LoneSoldier728> then one directly?
[16:30:47] <remonvv> LoneSoldier728: I use either directly or my own Java mapper
[16:31:05] <remonvv> The former works because it's supposed to and the latter works because I make sure it does.
[16:31:24] <LoneSoldier728> right
[16:31:43] <remonvv> If you're not 100% on MongoDB syntax I'd start with doing it directly on the JS driver.
[16:31:50] <LoneSoldier728> the good thing about mongoose is the setup of a schema even tho mongo is schema-less
[16:31:53] <remonvv> And add mongoose once you can map one to the other reliably.
[16:31:54] <ron> remonvv: well?
[16:32:01] <remonvv> I'm pretty sure mongoose supports all of this
[16:32:18] <remonvv> ron: Unlikely buddy, sorry ;) We don't do part time and we don't do off-site
[16:32:19] <LoneSoldier728> anyway you can look at the doc and see if im missing something
[16:32:24] <LoneSoldier728> http://mongoosejs.com/docs/guide.html
[16:32:47] <remonvv> LoneSoldier728: I'm not going to learn mongoose to help you out kind sir ;) There are limits to what you can expect from a support channel :)
[16:33:07] <remonvv> Perhaps #mongoose exists or try SO
[16:33:26] <remonvv> In the latter case be so kind to post a clear schema and your problem
[16:33:36] <ron> remonvv: make an exception. I'm worth it.
[16:33:52] <LoneSoldier728> damn, i was actually expecting you to code it all jk
[16:33:59] <LoneSoldier728> ron what are your skills?
[16:34:09] <remonvv> ron: I don't have the clout here to hire people. I'm a mere developer.
[16:34:15] <ron> LoneSoldier728: I'm fairly good at yelling at people.
[16:34:31] <ron> remonvv: umm, what?
[16:34:31] <LoneSoldier728> with any programming knowledge?
[16:34:35] <LoneSoldier728> or just yelling
[16:34:46] <ron> I know Java. So I yell in that reference.
[16:34:48] <remonvv> LoneSoldier728: He's a bit of both. And he likes dresses.
[16:34:57] <remonvv> ron: Are we connected on LI?
[16:35:03] <ron> Yes.
[16:35:11] <remonvv> ron: Oh. Disregard then.
[16:35:25] <LoneSoldier728> Want to connect guys with me : )
[16:35:30] <ron> remonvv: so you really don't like me... ok.
[16:35:33] <LoneSoldier728> I feel left out
[16:35:40] <ron> good. fits your nick.
[16:35:42] <remonvv> ron: Just in case you're serious; I really can't make exceptions ;)
[16:35:49] <LoneSoldier728> Lgavra.com
[16:35:53] <ron> you can. you just don't want to.
[16:35:55] <LoneSoldier728> is my site aka
[16:36:02] <LoneSoldier728> my linkedin is on the bottom
[16:36:14] <ron> oh crap
[16:36:16] <ron> you're israeli
[16:36:24] <LoneSoldier728> my code works beautifully right now except for the date removal, I will deal with that later tho
[16:36:26] <LoneSoldier728> yeah
[16:36:32] <LoneSoldier728> @ron
[16:36:37] <remonvv> LoneSoldier728: You can connect on LI
[16:36:50] <ron> I know. you don't need to approve it. your name screams israeli.
[16:37:00] <LoneSoldier728> yeah Lior
[16:37:05] <LoneSoldier728> is my first name
[16:37:12] <LoneSoldier728> I am assuming you see it on my site anyways
[16:37:23] <LoneSoldier728> I actually just came back from israel
[16:37:28] <ron> I got it from your site.
[16:37:29] <LoneSoldier728> a 3 weeks ago
[16:37:48] <LoneSoldier728> I live in manhattan, israel background
[16:37:52] <LoneSoldier728> israel*
[16:37:53] <ron> oh, and you're gay. so cute.
[16:37:55] <LoneSoldier728> israeli*
[16:38:14] <LoneSoldier728> Did I put that out in the public
[16:38:20] <LoneSoldier728> damn, where did you find out?
[16:38:27] <ron> no, but your facebook profile picture is with another guy.
[16:38:31] <ron> no straight guy would do that.
[16:38:32] <ron> :)
[16:38:34] <LoneSoldier728> my brother lol
[16:38:38] <ron> mhmm
[16:38:48] <remonvv> LoneSoldier728, what's your LI?
[16:38:53] <ron> dude, there's nothing wrong with it
[16:39:03] <ron> remonvv: IT"S IN HIS FUCKING WEBSITE
[16:39:07] <ron> why won't you hire me?
[16:39:08] <ron> :(
[16:39:22] <LoneSoldier728> http://www.linkedin.com/profile/view?id=50463214
[16:40:02] <LoneSoldier728> ron why do you want him to hire you so bad lol
[16:40:14] <ron> because I need a job?
[16:40:19] <ron> not that complicated.
[16:40:25] <Zelest> get one!
[16:40:28] <Zelest> not that complicated.
[16:40:33] <remonvv> LoneSoldier728, can't add you without InMail apparently
[16:40:34] <remonvv> http://www.linkedin.com/in/remonvanvliet
[16:40:52] <remonvv> LoneSoldier728: It's because he wants to work for someone that walks that fine line between brilliant and beautiful
[16:40:55] <LoneSoldier728> yeah need an email no?
[16:41:01] <remonvv> mhm
[16:41:07] <LoneSoldier728> wanna dcc me it
[16:41:11] <LoneSoldier728> and ill dcc u mine too
[16:41:37] <ron> dcc? for email? wtf
[16:42:33] <LoneSoldier728> i didnt want to throw it out there
[16:42:37] <LoneSoldier728> you have an LI ron?
[16:42:40] <remonvv> lol, oldschoolin' this
[16:42:48] <ron> Yes, I do.
[16:42:58] <ron> throw it out there? just use /msg
[16:43:31] <LoneSoldier728> when i say dcc i meant message
[16:44:17] <ron> but those are two completely different things
[16:44:28] <remonvv> I DCC-ed
[16:44:34] <remonvv> Takes me back to the 90's
[16:45:40] <LoneSoldier728> oh ya lol
[16:46:16] <ron> remonvv: so, about the job...
[16:49:06] <remonvv> ron: What job?
[16:49:12] <remonvv> ron: Who are you?
[16:49:28] <ron> remonvv: do you use skype?
[16:49:39] <remonvv> ron: Reluctantly
[16:49:48] <ron> remonvv: in that case, (finger)
[16:50:22] <remonvv> (mooning)
[16:50:53] <ron> remonvv: see, I managed to add LoneSoldier728 on linkedin without his email. you must be an idiot.
[16:51:01] <ron> I'm *that* good.
[16:51:02] <ron> :D
[16:51:53] <remonvv> ron: I'll have you know my LI is rather wonky. It currently says I should upgrade to premium to do X, I'm upgraded.
[16:52:00] <remonvv> Also, (finger)
[16:52:24] <ron> remonvv: okay. then again, you pay for LI, so (rofl)
[16:52:58] <remonvv> ron : http://www.quickmeme.com/meme/3vamxp/
[16:53:08] <remonvv> ron: I don't. Company does ;)
[16:53:19] <ron> remonvv: :)
[16:53:56] <remonvv> ron: Did that make you smile a little?
[16:54:05] <remonvv> ron: I'm here to make you happy afterall
[16:54:18] <ron> remonvv: then hire me, damnit
[16:54:25] <remonvv> ron: Not that happy.
[16:54:37] <ron> (finger)
[16:54:54] <remonvv> How rude.
[16:56:05] <ron> not as rude as not hiring me.
[16:56:41] <remonvv> Off for food and such
[16:56:42] <remonvv> bbl
[16:56:43] <remonvv> tata
[16:56:46] <LoneSoldier728> thanks
[16:56:47] <LoneSoldier728> later
[18:02:41] <_jo_> Ohai Mongodb. Any guesses why my query collection.find({'poll':{'$ne':null}}) returns nothing even though I have some entries with poll = [1, 2, 3]?
[18:02:58] <_jo_> It seems like {'$ne':null} evaluates to true when an item is an array.
[18:03:19] <Nodex> try not quoting the $ne
[18:03:48] <Nodex> plus null is a real value in mongodb
[18:04:02] <_jo_> No. :(
[18:04:12] <Nodex> if you're looking for things where the field doesn't exist use $exists:false
[18:04:17] <_jo_> Rather, '$ne' works the same as $ne.
[18:04:26] <_jo_> The field does exist and is populated by an array.
[18:04:46] <_jo_> Problem is the field seems to evaluate as null.
[18:04:53] <_jo_> It works fine for non-array entries.
[18:05:26] <_jo_> {'user:{'$ne':null}} works correctly.
[18:05:51] <Nodex> that is strange
[18:07:01] <Nodex> doesn't seem like it should be intended behaviour
[18:07:33] <_jo_> {'poll': {'$ne':[]}} returns all the items, even those without polls.
[18:07:45] <_jo_> (Except those where the poll is just [].
[18:07:46] <_jo_> )
[18:08:21] <Nodex> what does $ne:"" return?
[18:08:46] <_jo_> Everything. Those with and without the poll field.
[18:09:14] <Nodex> what does $not : {$ne : ""} return?
[18:09:32] <_jo_> Nothing.
[18:09:50] <Nodex> are all polls of the type array ?
[18:09:55] <_jo_> Yes.
[18:10:03] <_jo_> All polls are either arrays or null.
[18:10:15] <_jo_> Or the field doesn't exist.
[18:10:33] <Nodex> to get round it you can do $not : {$type : 4}
[18:10:40] <_jo_> I want to select only those where (1)the field exists, and (2)the value is not none.
[18:10:42] <Nodex> but you should file a jira issue
[18:10:44] <_jo_> Trying it.
[18:11:01] <Nodex> that will select everything that's not an array
[18:11:31] <_jo_> I want to select the documents where the poll is an array.
[18:11:48] <Nodex> to get round it you can do {$type : 4}
[18:11:52] <Nodex> $type : 4
[18:12:09] <_jo_> Nothing returned.
[18:12:19] <_jo_> {'poll':{$type : 4}}
[18:12:29] <_jo_> Oh. Maybe I have to put in quotes the type.
[18:12:55] <_jo_> Nope. :(
[18:13:11] <_jo_> Same result as {'poll':{$ne : null}}}
[18:13:11] <Nodex> that's weird
[18:14:28] <Nodex> sorry, this is weird behaviour
[18:14:43] <Nodex> https://jira.mongodb.org/browse/SERVER-1475
[18:15:22] <was85> Hi there, I'm using mongo db for the first time, but I'm unable to connect to remote db :( Can someone tell me how to do it?
[18:15:35] <Nodex> that is some very very stupid bevahiour on $type
[18:15:53] <Nodex> was85 : on your shell type "mongo" - without the quotes
[18:17:09] <was85> Nodex: I'm able to connect using the command line and gui tool, but unable to connect using the code
[18:17:24] <Nodex> code?
[18:17:54] <was85> I mean from node js mongodb package
[18:18:05] <Nodex> perhaps state that in the first place then?
[18:20:07] <was85> yeah should've mentioned this in the first place, I'm having problem with connection string
[18:20:24] <Nodex> pastebin yur code, perhaps someone can help
[18:20:35] <_jo_> Nodex: {'poll':{$size:2}} returns two results.
[18:20:44] <_jo_> {'poll':{$size:{$gt:0}}} returns 0.
[18:21:45] <_jo_> Ah! Found a workaround.
[18:21:50] <_jo_> Same bug report you linked. Thanks!
[18:26:45] <Nodex> no probs
[18:45:58] <drag> Is an _id value assigned when I create a DBObject or afterwards?
[18:56:45] <WDC> Hello all. I have sent a text index on a collection and do a db.col.runCommand("text", {search: "text search", limit: 10}) and get the following error: { "ok" : 0, "errmsg" : "can't find ns" }
[18:57:25] <WDC> What does the "can't find ns" error mean?
[19:20:49] <TommyCox> I'm pretty sure that means you're not using the right name for the collection
[19:20:57] <TommyCox> WDC ^^
[19:35:37] <LoneSoldier728> https://gist.github.com/anonymous/6082942
[19:35:37] <LoneSoldier728> getting an error
[19:35:37] <LoneSoldier728> for mongoose 12 or 24 bytes
[19:35:37] <LoneSoldier728> thing anyone know why?
[19:36:58] <WDC> thanks TommyCox
[19:54:17] <aleszoulek> hey guys
[19:55:06] <aleszoulek> Could you help me with replicaset a bit? I had three instances lets say m1 (primary), m2 and m3. m1 and m3 died. So I have just m2, which is sencondary
[19:55:24] <aleszoulek> When I try to reconfig replica set from m2, it says, that I need to call it on primary
[19:55:29] <aleszoulek> But primary is dead.
[19:55:45] <aleszoulek> "errmsg" : "replSetReconfig command must be sent to the current replica set primary.",
[19:56:04] <aleszoulek> How do I do that, when the rest of the cluster isn't there?
[19:56:13] <aleszoulek> Can I tell m2, that the rest is dead?
[20:30:51] <drag> What exactly is the purpose of the WriteResult? Is it just to hold any errors or concerns that occur during write?
[20:35:25] <cheeser> essentially
[20:37:08] <drag> cheeser, so after a write/update, if I call the getError() method on the returned WriteResuilt and it's null, no errors occurred, right?
[20:38:40] <cheeser> that will probably vary based on your WriteConcern
[20:44:22] <drag> cheeser, let me ask it this way, can the getErrors() method ever return a non-null value if that everything went fine and the writeConcern was set to 1?
[20:45:59] <cheeser> i can only speak to the java driver behavior but i *believe* that WriteResult.getResult() will always be non-null with non-zero error codes.
[20:46:23] <cheeser> isOk() determines the error state generically and then you can get the actual code and/or message
[20:47:40] <jcromartie> is there a way to sort by one field and THEN by another? in a specific order?
[20:48:13] <cheeser> .sort({field1 : 1, field2: -1})
[20:50:05] <drag> cheeser, I'm using the java driver as well, bu tI don't see a getOk() method in the code or javadocs
[20:50:17] <drag> http://api.mongodb.org/java/current/com/mongodb/WriteResult.html
[20:50:38] <cheeser> com.mongodb.CommandResult#ok
[20:50:48] <cheeser> isOk() is in the 3.x version :)
[20:51:01] <cheeser> which is the project I have open
[20:51:02] <jcromartie> cheeser: thanks, I didn't realize the hash order was maintained
[20:53:38] <drag> cheeser, ok, so I need to get the last commandResult with getLastError() or getLastError(WriteConcern) and then call ok() on that? If true, then all good?
[20:53:57] <cheeser> i *think* so.
[20:54:12] <drag> cheeser, ok, thanks.
[20:57:47] <cheeser> sure
[22:04:36] <wc-> hi all, i just noticed i have 10 or 11 mongodb processes running on my box
[22:04:52] <wc-> i can do service mongodb stop and they die, but if i do a start all of them come back
[22:05:04] <wc-> should there be multiple mongodb's with the commnad line /usr/bin/mongod --config /etc/mongodb.conf
[22:05:09] <ranman> wc- what is your start script doing?
[22:06:01] <wc-> im not sure, trying to figure that out now
[22:07:21] <wc-> im using a script in /etc/init.d/mongodb
[22:07:29] <wc-> i dont remember ever changing that
[22:07:38] <wc-> but i have messed around with /etc/mongodb.conf
[22:07:59] <wc-> shouldnt there just be one mongodb process?
[22:08:11] <ranman> a few more questions:
[22:08:13] <ranman> 1. what os?
[22:08:18] <wc-> ubuntu
[22:08:26] <ranman> did you install from the ubuntu repo
[22:08:29] <ranman> or from the 10gen repo?
[22:08:32] <wc-> 12.10
[22:08:37] <wc-> 10gen i believe
[22:08:45] <wc-> db version v2.4.5
[22:08:51] <wc-> just updated
[22:08:53] <ranman> and how are you listing the processes?
[22:08:56] <wc-> htop
[22:09:09] <wc-> ohh is this an htop thing?
[22:09:13] <wc-> top just has 1 process
[22:09:13] <ranman> and they have different pids and not just diff threads?
[22:09:22] <wc-> i just started using htop today
[22:09:41] <wc-> htop shows different pid's
[22:10:40] <ranman> do you think it could be this: http://unix.stackexchange.com/questions/10362/why-does-htop-show-more-process-than-ps
[22:10:41] <wc-> top just shows one mongodb process
[22:11:43] <wc-> yup
[22:11:44] <wc-> that fixed it
[22:11:48] <wc-> jeez
[22:11:58] <wc-> i sat down to optimize some stuff on this box
[22:12:07] <wc-> and thought i had a bunch of mongodb's running and panicked
[22:12:12] <wc-> thanks
[22:12:38] <ranman> hahaha, no worries glad that fixed it.
[22:12:51] <wc-> now onto figuring out what queries are slow / need indexes
[22:13:09] <ranman> wc-: https://pypi.python.org/pypi/Dex/0.5.1
[22:13:16] <ranman> https://github.com/mongolab/dex
[22:13:16] <wc-> yes!
[22:13:20] <wc-> i was jut about to try that out
[22:13:28] <wc-> i remember when it first came out it looked awesome
[22:28:05] <wting> How do I escape colons in a mongo uri? e.g: user:password@host:port
[22:58:01] <wc-> hey ranman the dex docs all have a user:pass@host for the mongo uri
[22:58:09] <wc-> i dont think i have authentication since its all on localhost?
[22:58:17] <wc-> seems like it isnt working for watch mode
[23:00:19] <wc-> ahh nm got it