Mosql.Mongo (mosql v0.1.0)
Link to this section Summary
Functions
Extracts all the keys of the collection. If there are embedded fields within the collection it uses the dot notation to construct the key. E.g. parentField.embeddedField.childField
Extract only the list of keys in a document for the given document
Returns a cursor for all the documents for a given collection with a given batch size
Converts the mongo document map structure to flat key value pair. For example
checks if the mongo connection is alive
Link to this section Functions
collection_keys(collection, opts \\ [])
Extracts all the keys of the collection. If there are embedded fields within the collection it uses the dot notation to construct the key. E.g. parentField.embeddedField.childField
collections()
documents(collection, query)
extract_document_keys(document)
Extract only the list of keys in a document for the given document
find_all(collection, batch_size)
Returns a cursor for all the documents for a given collection with a given batch size
flat_collection(collection, opts \\ [])
flat_document_map(document)
Converts the mongo document map structure to flat key value pair. For example:
Input Mongo Document: %{ "_id" => "BSON.ObjectId<6277f677b99d8078d17d5918>", "attributes" => %{
"communicationChannels" => %{
"email" => "hello@mosql.io",
"phone" => "111222333"
},
"communicationPrefs" => "SMS",
"phoneNumberVerified" => true,
"randomAttributes" => %{
"app_source" => "web",
"channel" => "marketing",
"signup_complete" => "false"
},
"skipTutorial" => false,
"themeAttributes" => %{
"appearance" => "dark",
"automatic" => false,
"color" => "#cc00ff"
}
}, "city" => "San Francisco", "email" => "hello@mosql.io", "state" => "CA" }
Output: %{ "_id": "BSON.ObjectId<6277f677b99d8078d17d5918>", "attributes.communicationChannels.email": "hello@mosql.io", "attributes.communicationChannels.phone": "111222333", "attributes.communicationPrefs": "SMS", "attributes.phoneNumberVerified": true, "attributes.randomAttributes.app_source": "web", ... ..... "city": "San Francisco", "state: "CA" }
insert(collection, data)
is_alive?()
checks if the mongo connection is alive