Module: Montage::Client::Documents

Included in:
Montage::Client
Defined in:
lib/montage/client/documents.rb

Instance Method Summary collapse

Instance Method Details

#create_or_update_documents(schema, documents) ⇒ Object

Public: Create or update a set of documents

Params:

schema   - *Required* The name of the schema to add the document to
document - *Required* The Hash representation of the document you would like to create

The document must conform to the schema definition

Returns a Montage::Response



71
72
73
# File 'lib/montage/client/documents.rb', line 71

def create_or_update_documents(schema, documents)
  post("schemas/#{schema}/save/", "document", documents)
end

#delete_document(schema, document_uuid) ⇒ Object

Public: Delete a document

Params:

schema        - *Required* The name of the schema the document belongs to
document_uuid - *Required* The uuid of the document you widh to delete

Returns a Montage::Response



96
97
98
# File 'lib/montage/client/documents.rb', line 96

def delete_document(schema, document_uuid)
  delete("schemas/#{schema}/#{document_uuid}/", "document")
end

#documents(queries) ⇒ Object

Public: Get a list of documents. Batch and single queries are supported via the formatting listed below.

  • Args :

    • queries -> A Montage::Query object or batch of objects to pass along with the request

  • Returns :

    • A Montage::Response with a raw body that will resemble:

    {
      "data"=> {
        "query1"=> [
          {
            "name"=>"happy accidents everywhere",
            "price"=>"999,999,999",
            "signed"=>true,
            "id"=>"-1"
          }
        ]
      }
    }
    
  • Examples :

    • A Single Query :

    {
      "query1" => {
        "$schema" => "bob_ross_paintings",
        "$query" => [
          ["$filter", [
            ["rating", ['$gt', 8]]
          ]],
          ["$limit", 1]
        ]
      }
    }
    
    • Batch Queries :

    {
      query1: { '$schema': 'bob_ross_paintings', ... },
      query2: { '$schema': 'happy_little_trees', ... }
    }
    


46
47
48
# File 'lib/montage/client/documents.rb', line 46

def documents(queries)
  post("query/", "document", queries)
end

#update_document(schema, document) ⇒ Object

Public: Update a document

Params:

schema        - *Required* The name of the schema the document belongs to
document_uuid - *Required* The uuid of the document you wish to update
document      - *Required* The Hash representation of the document you would like to update

The document must conform to the schema definition

Returns a Montage::Response



85
86
87
# File 'lib/montage/client/documents.rb', line 85

def update_document(schema, document)
  post("schemas/#{schema}/save/", "document", document)
end