PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Sunday the 24th of November, 2013

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[02:28:56] <FatBoyXPC> Went looking through modifiers came up short. I want to update a specific document. The field I want to update is also an object. So I kind of want to addToSet but this isn't an array, it's just another object. How can I accomplish this?
[02:31:47] <FatBoyXPC> For clarification, my document looks like: {_id:objectid(), name:"etc", someObj:{key:value,key2:val2}} something like that
[02:32:09] <FatBoyXPC> what I want to do is add another key/value to the "someObj" but I don't want to overwrite it.
[02:37:26] <drjeats> db.yourcollection.update({'_id':id}, {'$set': {'someObj.key3':val3}}) should do it
[02:41:20] <FatBoyXPC> that removed the existing keys :(
[02:41:34] <FatBoyXPC> ohw ait, I didn't do someObj.key3
[02:41:34] <FatBoyXPC> crap
[02:41:40] <drjeats> yeah, you need that
[02:41:43] <FatBoyXPC> Can I do it w/o someObj.key?
[02:41:50] <FatBoyXPC> yeah once I saw that mistake was obvious
[02:41:57] <drjeats> how else would it know what key to write?
[02:43:06] <FatBoyXPC> that's why addtoset would be amazing on an obj instead of array :P
[02:43:18] <FatBoyXPC> the issue is i want to add a bunch of these adn don't want to type obj.to all of them
[02:43:51] <drjeats> ah, someObj is an unknown key?
[02:44:17] <drjeats> or you just don't want to overwrite key3 if it's already there?
[02:45:00] <FatBoyXPC> I don't want to overwrite AND I know what someobj si but I'll have ot be adding it for like 200+ entries
[02:45:13] <FatBoyXPC> by entries I mean, I haev like 200 keys to add.
[02:47:38] <drjeats> sounds like you're gonna have 200 queries
[02:47:46] <drjeats> s/queries/updates
[03:40:49] <FatBoyXPC> i really don't want to have 200 queries, there's gotta be a better way
[03:40:52] <FatBoyXPC> Can I do an update off a select?
[03:41:12] <FatBoyXPC> more specifically can I do something like field: field + {}?
[03:43:11] <FatBoyXPC> sort like in js I can do obj.concat({key:val})
[04:18:10] <Drewch> Can someone tell me if there's something wrong with my TTL index? https://gist.github.com/Drewch/7623265
[04:18:35] <Drewch> I have one entry (it's in the gist), and I'm expecting it to be expired from the table, but it's still there
[04:26:33] <Drewch> People in stack overflow talking about seeing TTLMontior running in the logs, but I don't see that at all
[04:41:48] <Drewch> Can I use TTL indexes when running mongos locally?
[09:52:44] <sikor_sxe> hello, i have a problem with the node driver (MongoClient) for some reason it fails to perform simple find() operations. "collection.find().toArray(function(err, result) {});" will result in a TypeError, claiming there is no method "toArray()". (although this code used to work) Anyone got a hint what might be wrong? http://pastebin.com/rQFqVzW2
[10:22:46] <kali> sikor_sxe: you need to get the toArray inside the callback
[10:23:03] <sikor_sxe> it's a bug
[10:23:18] <sikor_sxe> https://jira.mongodb.org/browse/NODE-92
[10:24:09] <sikor_sxe> a new driver version was released yesterday, and as far as i understand it, some autodoc stuff removed crucial () statements
[10:28:38] <kali> sorry, i'm not very fluent on node.js... what do you expect when doing collection.find().toArray(function(err, result) {}); ?
[10:29:07] <kali> a blocking call on the find(), i assume, but why bother make the toArray() async ?
[10:29:33] <kali> ha, find() is local... mmmm ok
[10:29:40] <kali> nevermind
[10:38:42] <sikor_sxe> the call is not blocking, when toArray() or sort() are called set, i assume it's just using their callbacks
[15:11:25] <Nodex> Derick : ping
[16:19:09] <Derick> Nodex: pong
[16:20:45] <Nodex> quick question about the returns from Mongodb in a find (php) if you have a sec ?
[16:22:51] <Nodex> https://gist.github.com/anonymous/7628919
[16:23:21] <Nodex> is that intended behaviour...
[16:23:34] <Derick> yes
[16:23:47] <Nodex> ia there anyway to override it
[16:23:51] <Nodex> is*
[16:23:58] <Derick> not currently - I think there is a jira ticket for it
[16:24:18] <Nodex> ah cool, i've been going mad all day trying to get round it haha
[16:24:23] <Derick> but it's marked as "won't fix" - ie, don't use keys that consist of numbers, as PHP can't make the distinction
[16:24:45] <Nodex> I need the numeric keys - I am not querying on it, it's simply storing a schema and the numbers represent things
[16:25:27] <Nodex> current;y I just use JSON_FORCE_OBJECT on json_encode() but it's a little hacky and I would like to simply output the whole object without having to loop each key/value
[16:25:51] <Nodex> if it's never going to be fixed I'll have to store them elsewhere as Json strings I guess
[16:27:24] <Nodex> the strange thing is this... if you store {"0":1,"1":2} it comes out as [1,2] but if you store "1":1,"2":2, it comes out as an object {"1":1,"2":2}
[16:27:51] <Nodex> it only effects arrays that START at zero and are concurrent - any skips or breaks and it stores the key/value as an object
[16:27:56] <Derick> yes
[16:28:29] <Derick> it's how the driver detects associative arrays (objects) vs numerical arrays in JSON
[16:28:54] <Nodex> but I wouldve' thought that if php can't distinct between numbers and strings as keys (when they're stringified numbers) then whether they start at zero or not wuld be irrelevant
[16:29:51] <Nodex> it wouldn#t be a problem but I ingerited a structure that starts with Zero's in 3 out of 20 keys haah
[16:29:54] <Nodex> haha*
[16:30:01] <Nodex> inherited*
[16:30:16] <Nodex> anyway, thanks for the clarification, have a good rest of day ;)
[21:21:18] <Drewch> Can someone tell me if there's something wrong with my TTL index? https://gist.github.com/Drewch/7623265
[21:21:28] <Drewch> I don't see TTL Monitor running in my logs either
[22:06:15] <joannac> Drewch: That's not a BSON date
[22:06:29] <joannac> check the example here http://docs.mongodb.org/manual/tutorial/expire-data/#expire-after-a-certain-number-of-seconds
[22:06:51] <joannac> actually, wait.
[22:07:18] <Drewch> I read that java.util.Date is a bson date using java mongo driver
[22:07:25] <Drewch> which turns it into ISODate
[22:08:18] <Drewch> I've also tried straight from Mongo though, following that example and using that date type
[22:08:23] <joannac> yeah, you don't have an ISODate
[22:09:21] <joannac> there's a typo on that page I linked you :(
[22:09:38] <Drewch> oh :(
[22:10:13] <joannac> But what I said applies. Your "status" field isn't an ISOdate
[22:13:06] <Drewch> I shall update it and use direct mongo commands instead of java and try again
[22:14:59] <Drewch> Okay, updated: https://gist.github.com/Drewch/7623265 -- How does it look?
[22:15:10] <Drewch> I'm tailing logs for TTL Monitor prints
[22:19:58] <joannac> You're not going to see it in the mongod log unless you've changed the log level
[22:21:48] <floatingpoint> how would I go about printing a value returned from a findOne() query (that is limited to a single field)
[22:29:05] <joannac> floatingpoint: same way you would with a normal find() -- give it a projection argument
[22:29:45] <floatingpoint> joannac like this: var somedata = UserLib.getUserPassword(name, function(err) { console.log(err) });
[22:29:46] <floatingpoint> ?
[22:30:07] <floatingpoint> I end up with TypeError: object is not a function when I try to load the data
[22:31:15] <floatingpoint> additionally, how can I determien what DB i am connecting to?
[22:34:29] <Lobosque> how do I change the values of a collection returned by a find? My try is var test = Fretes.find({}).map(function(i) { i.from = 'test'; }); but test comes as undefined.
[22:34:56] <joannac> floatingpoint: that doesn't look like mongodb syntax
[22:36:10] <floatingpoint> joannac sorry. here's the statement: return users.findOne({ username: username }, { password: true });
[22:36:40] <floatingpoint> what exactly gets returned? a string? a json array? some other object?
[22:36:50] <joannac> Lobosque: You need to return something from your map object
[22:37:06] <joannac> floatingpoint: should be {password:1}
[22:37:07] <floatingpoint> oh. a document
[22:37:32] <floatingpoint> joannac http://docs.mongodb.org/manual/reference/method/db.collection.findOne/
[22:37:37] <floatingpoint> specifies that true is ok
[22:37:43] <floatingpoint> is that incorrect?
[22:38:33] <Lobosque> joannac that makes sense :) thank you
[22:39:14] <joannac> floatingpoint: oh, i guess that's fine then. I always use 1
[22:39:28] <joannac> floatingpoint: okay, so what does that return?
[22:39:53] <joannac> I would quote your keys by the way, since you're using variables
[22:40:05] <floatingpoint> joannac ok. how would I find out what it returns? I expect it to return a document containing a single field
[22:40:21] <joannac> floatingpoint: document with _id and password
[22:40:52] <joannac> floatingpoint: why don't you run it and see what it returns?
[22:41:09] <floatingpoint> so, if I did: users.findOne({ username: username }, { password: 1 }).password; a string would be returned, correct?
[22:42:14] <floatingpoint> joannac TypeError: Cannot read property 'password' of undefined
[22:42:32] <floatingpoint> however, I know the data in question exists in the database
[22:42:45] <joannac> run the findOne, and see what you get
[22:43:14] <floatingpoint> TypeError: object is not a function
[22:43:36] <joannac> are you doing this in the mongo shell?
[22:44:21] <floatingpoint> no I am doing it in javascript
[22:44:44] <floatingpoint> I'm thinking the DB might not be correct
[22:46:03] <floatingpoint> nope. it works
[22:47:39] <floatingpoint> joannac also, when I do it in mongodb I get a valid result
[22:47:47] <floatingpoint> so what's going on here?
[22:48:15] <joannac> floatingpoint: then you're messing something up when you set up your db connection, or your collection, or something
[22:48:36] <floatingpoint> joannac sec. let me show you what it looks like
[22:49:44] <floatingpoint> joannac http://pastebin.com/Nseqqqva
[22:51:08] <floatingpoint> looks kosher, no?
[22:54:33] <joannac> you don't actually create a MongoClient object?
[22:55:01] <floatingpoint> joannac? var MongoClient = mongodb.MongoClient;
[23:00:58] <joannac> well, go through step by step
[23:01:18] <joannac> do you have a valid db? is users a valid collection
[23:01:37] <floatingpoint> how do I determine if a connection to a database is valid?
[23:06:43] <joannac> well, firstly, is it null?
[23:07:04] <joannac> if it's not, can you list connections? can you get db stats?
[23:07:10] <joannac> just basic debugging
[23:08:29] <floatingpoint> it should return null
[23:08:35] <floatingpoint> http://mongodb.github.io/node-mongodb-native/api-generated/mongoclient.html
[23:09:33] <synesp1> I have an issue I need some advice on - I have a collection where I write a document for every click in a web app. Suddenly, the clicks weren't being written and there were no errors from the insert.
[23:09:50] <synesp1> I performed a remove on the collection and suddenly it was writing again..
[23:09:54] <synesp1> any insight?
[23:10:11] <joannac> synesp1: what do the logs say?
[23:11:18] <joannac> floatingpoint: did you check the err then?
[23:11:33] <synesp1> no error, nothing
[23:11:39] <synesp1> nothing out of the ordinary in the logs
[23:12:15] <synesp1> I'm going to wait for it to happen again, I also tried testing in the test environment and it wouldn't write either
[23:12:23] <synesp1> problem is, I did the remove and restarted mongod (so im not sure which fixed it)
[23:12:39] <synesp1> any logging I can turn on .. more verbose?
[23:13:46] <joannac> either turn on profiling or up loglevel or verbose or some combination
[23:14:13] <joannac> if you're writing a document per update though, you're going to be generating a lot of i/o
[23:16:02] <floatingpoint> joannac err is undefined
[23:22:24] <Drewch> joannac - thanks btw!