PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Thursday the 17th of May, 2018

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[05:39:55] <lqez> good morning
[08:51:01] <Dal_Ri> Hi, good mornign, buonagiornata, bom dia! I need to build a family tree app, and I like to know if someone have any tip to help-me building data structure for that, and if mongodb is a good DB for that. Thank you!
[09:17:39] <doberman> When using PHP mongodb lib 1.1.1 and PHP mongodb extension 1.2.0, querying the db resulted in {"test":[ObjectId("...")]} document being returned as ["test":[[".."]] . After updating to php lib 1.3.2 and php extension 1.4.3 the returned data is ["test":[{"$oid":"..."})]] by the query. How can I configure it to return as it did previously? Can someone help on what changed? Any hints are appreciated.
[09:18:47] <Derick> is that after converting things to JSON?
[09:18:54] <Derick> as ObjectID(" ... isn't really valid
[09:19:37] <doberman> @Derick that would be correct, I'm used to seeing the output of shell mode which is ObjectID()
[09:19:53] <Derick> yes, but as that's not valid JSON, we've fixed that
[09:20:03] <Derick> the *new* format, should also be acceptable by the shell though
[09:21:08] <doberman> Are you referring to mongo server change, or lib/driver changes?
[09:22:08] <Derick> lib/driver changes
[09:22:21] <Derick> all drivers started implementing the "new" extended json spec
[09:22:26] <Derick> before that, we all did something different
[09:23:05] <Derick> https://github.com/mongodb/specifications/blob/master/source/extended-json.rst « in case you want to see it
[09:23:11] <doberman> Is there any setting to tell the driver to return hex string instead of {"$oid":"string"} ?
[09:23:26] <Derick> the string in that example should be he hex string
[09:23:36] <Derick> how do you obtain the json string?
[09:24:29] <Derick> there are unlikely to be options for this though, but I'm curious as to how you get to the string, and how they're useful to you. In most cases, it should just be for debug purposes?
[09:26:15] <doberman> I'm not sure which string do you refer to. When connecting to the DB we're using the typeMap driver options and set document > array, root > array. The query result was always {"test":"hexadecimal string"} instead of {"test":{"$oid":"hexadecimal string"}}. Hope this makes sense?
[09:26:39] <Derick> no, because the driver returns PHP variables, not json strings
[09:27:16] <Derick> so it would have returned [ 'test' => \MongoDb\BSON\ObjectID(...) ]
[09:27:21] <Derick> and it should still do that...
[09:27:39] <doberman> Understood. So probably my question is related to the lib, not the driver?
[09:28:10] <Derick> no... I don't understand why you care about the json strings that are made from these PHP variable structures tbh
[09:28:45] <doberman> Because right now instead of returning list of strings, we return list of {"$oid":"string"} objects to the clients
[09:29:52] <Derick> do you use json_encode or something?
[09:30:41] <Derick> can you show the bit of code that loops over the result set and converts them into json strings?
[09:31:13] <doberman> I see where you're getting with this. Let me debug the code and see the initial result returned by the ->query() call
[09:31:39] <Derick> I'm sure that should just return a cursor
[09:34:10] <doberman> @Derick Before doing json_encode() the data is correct and looks as with the older lib and driver.
[09:34:20] <Derick> I just checkd this with 1.2.0:
[09:34:28] <Derick> derick@singlemalt:~ $ cat /tmp/foo.php
[09:34:30] <Derick> <?php
[09:34:32] <Derick> $a = [
[09:34:34] <Derick> 'test' => new \MongoDB\BSON\ObjectID(),
[09:34:36] <Derick> ];
[09:34:38] <Derick> echo json_encode( $a );
[09:34:40] <Derick> output:
[09:34:42] <Derick> {"test":{"$oid":"5afd4c90122d330d425d43b1"}}
[09:35:08] <doberman> Exactly the problem.
[09:35:26] <doberman> So, is there any way that this can output to {"test":"5afd4c90122d330d425d43b1"} ?
[09:35:28] <Derick> I'm saying it has always done that :)
[09:35:54] <doberman> Well, that's incorrect :)
[09:35:54] <Derick> not true, as in 1.1.1, it doesn't return the ObjectID at all:
[09:36:02] <Derick> {"test":{}}
[09:36:10] <Derick> (with 1.1.1)
[09:36:56] <doberman> Maybe typeMap helps on that?
[09:37:08] <Derick> no, I don't think so
[09:37:18] <Derick> the typemap doesn't get in the way of php variables to json-string
[09:37:22] <doberman> It definitely returns it as string with 1.1.1 for us, using lib 1.2.0
[09:37:28] <doberman> s/lib/ext/
[09:37:34] <Derick> I am *just* testing the driver (extension) here
[09:38:43] <doberman> I'm completely confused. With lib 1.1.1 and driver (extension) 1.2.0 it json_encode() resulted to {"test":"string"}
[09:39:09] <doberman> Now with lib 1.3.2 and driver (extension) 1.4.3 with json_encode() results to {"test":{"$oid":"string"}}
[09:39:09] <Derick> doberman: I got to go, but, if you want, feel free to email me a (full executable) snippet that produces this with the different drivers (ignoring the library first)
[09:39:25] <doberman> Will do Derick, please let me know of your email
[09:39:29] <doberman> I really appreciate your help!
[09:39:36] <Derick> it's nick @mongodb.com
[09:39:42] <doberman> Thank you
[09:39:55] <Derick> (not literally "nick", of course)
[09:40:02] <doberman> Got it :D
[09:50:48] <doberman> @Derick Just FYI, previously the PHP class of ObjectID was "MongoDB\BSON\ObjectID", and now it's "MongoDB\BSON\ObjectId". Still a very odd change. That was causing invalid detection by our code of the type. Issue solved. Thank you for your help again!
[19:45:22] <aFeijo> I am trying to access my mongo remotely but it say access denied, although the same command localy at where mongo is installed works. How can I make mongod accept remote connections?
[19:53:57] <aFeijo> I just noticed that my mongo is running as bindIpAll TRUE
[19:54:00] <aFeijo> should be working!
[20:20:07] <aFeijo> no hints?
[20:25:05] <aFeijo> can mongo client 2.4 connect to mongo server 3.6 ?
[21:21:22] <synaptech> hey all, had a quick update question for you. I'm trying to update an attribute on ~10k documents. The attribute use to be an array, but I'd like to update it to just be the first value in the array
[21:21:31] <synaptech> I'm trying something like this: https://pastebin.com/GUmze1EE
[21:21:44] <synaptech> (doing this from the mongo shell)
[21:22:42] <synaptech> any idea where I'm going wrong?