PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Tuesday the 30th of April, 2019

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[15:45:59] <al7ci3tti> hello all, and good day
[15:46:12] <al7ci3tti> i've got a question about InsertMany with the c# driver
[15:46:49] <al7ci3tti> I've been searching and I'm unable to find any easy way to insert a BsonArray
[15:46:55] <al7ci3tti> can anyone advise?
[15:49:47] <al7ci3tti> I have a json string which is an array of documents. I want to insert all of these documents into a collection.
[15:50:03] <al7ci3tti> The built-in methods don't seem to bridge this gap very well - am I missing something?
[15:50:39] <bluezone> I don't know anything about the C# driver
[15:50:56] <al7ci3tti> I seem to be able to get a BsonArray, but InsertMany takes an IEnumerable<BsonDocument>
[15:51:02] <bluezone> can you parse the json
[15:51:20] <bluezone> also I don't know much about c# sadly
[15:51:21] <al7ci3tti> that's my last resort...hoping to do this WITH the driver, not despite it
[15:52:30] <al7ci3tti> i think I just stumbled across what I need... surprised there are just no questions and answers for it
[15:52:42] <bluezone> https://stackoverflow.com/questions/6260936/adding-bson-array-to-bsondocument-in-mongodb
[15:52:46] <bluezone> this maybe
[15:52:56] <al7ci3tti> I can get BsonValues out, and they should all be BsonDocuments, so I can cast them and this should work.
[15:53:13] <bluezone> type systems can be annoying lol
[15:53:46] <al7ci3tti> thanks, but that link is about adding an array as a field
[15:54:54] <al7ci3tti> while I am still quite surprised that no one has asked this & gotten a response on SO or anywhere, this was still mostly my own fault for not looking at the types involved here
[15:55:04] <al7ci3tti> now to confirm that this works...
[15:57:25] <bluezone> I want to learn C#, heard it's must more palatable that Java
[16:00:34] <al7ci3tti> yeah...i have absolutely no loyalty toward MS but c# is nonetheless the best language that currently exists
[16:00:55] <al7ci3tti> still waiting eagerly for an even better replacement
[16:24:51] <GothAlice> Have a Java library you’d like to use, like a good NLTK or, say, Neo4J? Jython and import your Java libraries for direct use.
[16:25:24] <GothAlice> (<3 Neo4J.)
[20:33:53] <Popzi> Hey, I'm trying to do something absolutely absurdly whack-o crazy in mongo
[20:34:13] <Popzi> how do I select the last 10 items sorted by time?
[22:15:48] <GothAlice> Popzi: What's the type of your document's `_id` attribute? https://docs.mongodb.com/v2.6/reference/object-id/ ← if it's an ObjectId, the first field of the compound type is the timestamp of creation. You can sort on this to sort by record creation time. (You can also construct fake ObjectIds with just a date in them, and range query.)
[22:17:58] <GothAlice> So limit(10).sort({'_id': -1}) would get you the latest 10, but you could also say: filter({"_id": {"$gt": ObjectId.from_datetime(datetime.utcnow() - timedelta(minutes=5))}}).sort({'_id': -1}) "give me the last five minutes of activity, sorted most recent first.