Module: Ashikawa::AR::Search

Extended by:
ActiveSupport::Concern
Included in:
Model
Defined in:
lib/ashikawa-ar/search.rb

Overview

Provides Search functionality for your model

Class Method Summary collapse

Class Method Details

.allArray<Instance of Class>

Find all documents

Examples:

Find all documents

people = Person.people
people.first.name #=> Johnny

Returns:

  • (Array<Instance of Class>)


57
# File 'lib/ashikawa-ar/search.rb', line 57

def self.all;end

.by_example(example) ⇒ Array<Instance of Class>

Find all documents with the provided attributes

Examples:

Find a document by example

people = Person.by_example name: "Johnny"
people.first.name #=> Johnny

Parameters:

  • example (Hash)

    The attributes

Returns:

  • (Array<Instance of Class>)


38
# File 'lib/ashikawa-ar/search.rb', line 38

def self.by_example(example);end

.find(id) ⇒ Instance of Class

Find a document of the collection by ID

Examples:

Find a document by its ID

person = Person.find my_id
person.name #=> Johnny

Parameters:

  • id (Fixnum)

    ID of the document

Returns:

  • (Instance of Class)


18
# File 'lib/ashikawa-ar/search.rb', line 18

def self.find(id);end

.find_by_aql(query) ⇒ Array<Instance of Class>

Find a document using an AQL query

Examples:

Find documents with an AQL query

people = Person.find_by_aql "FOR u IN people RETURN u"
people.first.name #=> Johnny

Parameters:

  • query (String)

    The Query

Returns:

  • (Array<Instance of Class>)


28
# File 'lib/ashikawa-ar/search.rb', line 28

def self.find_by_aql(query);end

.first_example(example) ⇒ Instance of Class

Find the first document with the provided attributes

Examples:

Find a document by example

people = Person.first_example name: "Johnny"
people.name #=> Johnny

Parameters:

  • example (Hash)

    The attributes

Returns:

  • (Instance of Class)


48
# File 'lib/ashikawa-ar/search.rb', line 48

def self.first_example(example);end