abstract class RethinkORM::Base
- RethinkORM::Base
- ActiveModel::Model
- Reference
- Object
Included Modules
- ActiveModel::Callbacks
- ActiveModel::Validation
- RethinkORM::Associations
- RethinkORM::Index
- RethinkORM::Persistence
- RethinkORM::Queries
- RethinkORM::Table
- RethinkORM::Validators
Defined in:
rethinkdb-orm/base.crConstant Summary
-
AM_PARENT_TYPE =
{:type => RethinkORM::Base} of Nil => Nil -
DEFAULTS =
{} of Nil => Nil -
FIELDS =
{id => {klass: String, converter: nil, mass_assign: true, should_persist: true, tags: {es_type: "keyword"}}} of Nil => Nil -
HAS_KEYS =
[true] -
INDICES =
[] of NamedTuple(field: String, table: String) -
LOCAL_FIELDS =
{id => {klass: String, converter: nil, mass_assign: true, should_persist: true, tags: {es_type: "keyword"}}} of Nil => Nil -
Macro level constants
-
PERSIST =
{id => {klass: String, converter: nil, mass_assign: true, should_persist: true, tags: {es_type: "keyword"}}} of Nil => Nil -
SETTERS =
{id => nil} of Nil => Nil -
TABLES =
[] of String
Class Method Summary
-
.all
Cursor of each model in the database
-
.attributes
You may want a list of available attributes
-
.changes(id : String | Nil = nil)
Establishes a changefeed of models in a RethinkDB table
-
.clear
Removes all records from the table
-
.count
Returns a count of all documents in the table
-
.count(**attrs)
Returns a count of all documents in the table
-
.count(&predicate : RethinkDB::DatumTerm -> RethinkDB::DatumTerm)
Returns a count of documents for which predicate block is true
-
.count(**attrs, &predicate : RethinkDB::DatumTerm -> RethinkDB::DatumTerm)
Returns a count of documents for which predicate block is true
-
.create(**attributes)
Creates the model
-
.create!(**attributes)
Creates the model
-
.exists?(id)
Check for document presence in the table
-
.find(id, **options)
Find single document by id
-
.find!(id, **options)
Lookup document by id
-
.find_all(ids, **options)
Look up document by id
-
.find_by(**attribute)
Returns documents with columns matching the given criteria
-
.get_all(ids, **options)
Query by ids, optionally set a secondary index
- .has_index?(field)
-
.raw_changes(id : String | Nil = nil)
Establishes a changefeed of raw JSON documents
-
.raw_query(&)
Unsafe method until
.wherecan accept more generic arguments Makes 2 LARGE assumptions - User correctly scopes the query under the right table - User forms a query that returns a collection of models -
.table_query(&)
Yield a RethinkDB handle namespaced under the document table
-
.where(&predicate : RethinkDB::DatumTerm -> RethinkDB::DatumTerm)
Returns documents for which predicate block is true
- .where(**attrs, &predicate : RethinkDB::DatumTerm -> RethinkDB::DatumTerm)
- .where(attrs : Hash)
-
.where(**attrs)
Returns documents containing fields that match the attributes
Instance Method Summary
-
#==(other : self)
Returns
trueif this reference is the same as other. -
#apply_defaults
Generate code to apply default values
-
#assign_attributes(id : String | Nil = nil)
Process attributes must be called while constants are in scope
-
#assign_attributes(params : HTTP::Params | Hash(String, String) | Tuple(String, String))
Accept HTTP params
-
#attributes
Returns a Hash of all the attribute values
-
#attributes_tuple
Returns a NamedTuple of all attribute values
-
#id_default : String | Nil
Attribute default value
-
#persistent_attributes
Returns a hash of all attributes that may be persisted
-
#uuid_generator=(generator : Class)
Allow user defined uuid generator
Instance methods inherited from module RethinkORM::Persistence
delete
delete,
destroy
destroy,
destroyed
destroyed,
destroyed=(destroyed)
destroyed=,
destroyed?
destroyed?,
new_record?
new_record?,
persisted?
persisted?,
reload!
reload!,
save(**options)
save,
save!(**options)
save!,
update(**attributes)
update,
update!(**attributes)
update!,
update_fields(**attributes)
update_fields
Instance methods inherited from module RethinkORM::Associations
reset_associations
reset_associations
Class Method Detail
Returns a count of documents for which predicate block is true
Returns a count of documents for which predicate block is true
Creates the model
Raises a RethinkORM::Error::DocumentNotSaved if failed to created
Returns documents with columns matching the given criteria
Could use .get_all, however this requires an index built on the queried field
TODO Implement get_all method once index functionality implemented
Unsafe method until .where can accept more generic arguments
Makes 2 LARGE assumptions
- User correctly scopes the query under the right table
- User forms a query that returns a collection of models
Should raise/not compile on malformed query/incorrect return type to create a collection
Returns documents for which predicate block is true
Instance Method Detail
Returns true if this reference is the same as other. Invokes same?.
Process attributes must be called while constants are in scope
Accept HTTP params