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

Link to this function

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

Link to this function

documents(collection, query)

Link to this function

extract_document_keys(document)

Extract only the list of keys in a document for the given document

Link to this function

find_all(collection, batch_size)

Returns a cursor for all the documents for a given collection with a given batch size

Link to this function

flat_collection(collection, opts \\ [])

Link to this function

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" }

Link to this function

insert(collection, data)

checks if the mongo connection is alive