-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
✒️ Description
Basically, I would want to find a document, or many documents that meet the requirements of a filter. BUT not send back all the bulky data that may be contained inside of that document. Sort of like a distinct query, but to only include certain whitelisted fields, or include everything but certain blacklisted fields.
luckily there are already database commands that do that for us!
🤔 Why?
Here's what I currently have to do for this, it's a bit more tedious, since you have to craft your own string, then split the documents yourself
#
# Output doc:
#_command-results::1 : {
# cursor : {
# firstBatch : [
# {doc1},
# {doc2},
# {etc}
# ]
# },
# ok : "1.0",
# $clusterTime : some timestamp bullshit,
# operationTime : int timestamp
#}
#
# ref: https://www.mongodb.com/docs/manual/reference/command/find/#output
set {_command-results::*} to results of mongo command "{""find"": ""my-collection"",""filter"": { ""player"": ""%{_uuid}%"" },""projection"": { ""_id"": 0, ""very-large-file-to-exclude"": 0, ""field-2-to-exclude"": 0 },}" of database {mongo-database}
# Convert the nested results into their own documents
loop {_command-results::*}:
set {_docs::*} to mongo embedded array with path "cursor.firstBatch" of loop-value```