new RethinkDBAdapter(opts)
RethinkDBAdapter class.
Parameters:
Name | Type | Argument | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object |
<optional> |
Configuration opts. Properties
|
Example
// Use Container instead of DataStore on the server import {Container} from 'js-data' import RethinkdbDBAdapter from 'js-data-rethinkdb' // Create a store to hold your Mappers const store = new Container() // Create an instance of RethinkdbDBAdapter with default settings const adapter = new RethinkdbDBAdapter() // Mappers in "store" will use the RethinkDB adapter by default store.registerAdapter('rethinkdb', adapter, { default: true }) // Create a Mapper that maps to a "user" table store.defineMapper('user')
Members
-
<static> OPERATORS
-
Default predicate functions for the filtering operators.
- Source:
Properties:
Name Type Description ==
function Equality operator.
!=
function Inequality operator.
>
function "Greater than" operator.
>=
function "Greater than or equal to" operator.
<
function "Less than" operator.
<=
function "Less than or equal to" operator.
isectEmpty
function Operator to test that the intersection between two arrays is empty.
isectNotEmpty
function Operator to test that the intersection between two arrays is NOT empty.
in
function Operator to test whether a value is found in the provided array.
notIn
function Operator to test whether a value is NOT found in the provided array.
contains
function Operator to test whether an array contains the provided value.
notContains
function Operator to test whether an array does NOT contain the provided value.
-
authKey :string
-
RethinkDB authorization key.
Type:
- string
-
bufferSize :number
-
Buffer size for connection pool.
Type:
- number
-
db :string
-
Default database.
Type:
- string
-
debug :boolean
-
Whether to log debugging information.
Type:
- boolean
-
deleteOpts :Object
-
Default options to pass to r#delete.
Type:
- Object
-
host :string
-
RethinkDB host.
Type:
- string
-
insertOpts :Object
-
Default options to pass to r#insert.
Type:
- Object
-
max :number
-
Maximum connections in pool.
Type:
- number
-
min :number
-
Minimum connections in pool.
Type:
- number
-
operators :Object
-
Override the default predicate functions for specified operators.
Type:
- Object
-
port :number
-
RethinkDB port.
Type:
- number
-
r :Object
-
The rethinkdbdash instance used by this adapter. Use this directly when you need to write custom queries.
Type:
- Object
-
raw :boolean
-
Whether to return a more detailed response object.
Type:
- boolean
-
runOpts :Object
-
Default options to pass to r#run.
Type:
- Object
-
updateOpts :Object
-
Default options to pass to r#update.
Type:
- Object
Methods
-
<static> extend(instanceProps, classProps)
-
Alternative to ES6 class syntax for extending
RethinkDBAdapter
.Parameters:
Name Type Argument Description instanceProps
Object <optional>
Properties that will be added to the prototype of the subclass.
classProps
Object <optional>
Properties that will be added as static properties to the subclass itself.
Returns:
Subclass of
RethinkDBAdapter
.- Type
- Object
-
afterCreate()
-
afterCreateMany()
-
afterDestroy()
-
afterDestroyAll()
-
afterFind()
-
afterFindAll()
-
afterUpdate()
-
afterUpdateAll()
-
afterUpdateMany()
-
beforeCreate()
-
beforeCreateMany()
-
beforeDestroy()
-
beforeDestroyAll()
-
beforeFind()
-
beforeFindAll()
-
beforeUpdate()
-
beforeUpdateAll()
-
beforeUpdateMany()
-
create(mapper, props, opts)
-
Create a new record.
Parameters:
Name Type Argument Description mapper
Object The mapper.
props
Object The record to be created.
opts
Object <optional>
Configuration options.
Properties
Name Type Argument Default Description insertOpts
Object <optional>
Options to pass to r#insert.
raw
boolean <optional>
false Whether to return a more detailed response object.
runOpts
Object <optional>
Options to pass to r#run.
Returns:
- Type
- Promise
-
createMany(mapper, props, opts)
-
Create multiple records in a single batch.
Parameters:
Name Type Argument Description mapper
Object The mapper.
props
Object The records to be created.
opts
Object <optional>
Configuration options.
Properties
Name Type Argument Default Description insertOpts
Object <optional>
Options to pass to r#insert.
raw
boolean <optional>
false Whether to return a more detailed response object.
runOpts
Object <optional>
Options to pass to r#run.
Returns:
- Type
- Promise
-
dbg()
-
destroy(mapper, id, opts)
-
Destroy the record with the given primary key.
Parameters:
Name Type Argument Description mapper
Object The mapper.
id
string | number Primary key of the record to destroy.
opts
Object <optional>
Configuration options.
Properties
Name Type Argument Default Description deleteOpts
Object <optional>
Options to pass to r#delete.
raw
boolean <optional>
false Whether to return a more detailed response object.
runOpts
Object <optional>
Options to pass to r#run.
Returns:
- Type
- Promise
-
destroyAll(mapper, query, opts)
-
Destroy the records that match the selection query.
Parameters:
Name Type Argument Description mapper
Object the mapper.
query
Object <optional>
Selection query.
Properties
Name Type Argument Description where
Object <optional>
Filtering criteria.
orderBy
string | Array <optional>
Sorting criteria.
sort
string | Array <optional>
Same as
query.sort
.limit
number <optional>
Limit results.
skip
number <optional>
Offset results.
offset
number <optional>
Same as
query.skip
.opts
Object <optional>
Configuration options.
Properties
Name Type Argument Default Description deleteOpts
Object <optional>
Options to pass to r#delete.
operators
Object <optional>
Override the default predicate functions for specified operators.
raw
boolean <optional>
false Whether to return a more detailed response object.
runOpts
Object <optional>
Options to pass to r#run.
Returns:
- Type
- Promise
-
filterSequence(mapper, query, opts)
-
Apply the specified selection query to the provided RQL sequence.
Parameters:
Name Type Argument Description mapper
Object The mapper.
query
Object <optional>
Selection query.
Properties
Name Type Argument Description where
Object <optional>
Filtering criteria.
orderBy
string | Array <optional>
Sorting criteria.
sort
string | Array <optional>
Same as
query.sort
.limit
number <optional>
Limit results.
skip
number <optional>
Offset results.
offset
number <optional>
Same as
query.skip
.opts
Object <optional>
Configuration options.
Properties
Name Type Argument Description operators
Object <optional>
Override the default predicate functions for specified operators.
-
find(mapper, id, opts)
-
Retrieve the record with the given primary key.
Parameters:
Name Type Argument Description mapper
Object The mapper.
id
string | number Primary key of the record to retrieve.
opts
Object <optional>
Configuration options.
Properties
Name Type Argument Default Description raw
boolean <optional>
false Whether to return a more detailed response object.
runOpts
Object <optional>
Options to pass to r#run.
with
Array.<string> <optional>
[] Relations to eager load.
Returns:
- Type
- Promise
-
findAll(mapper, query, opts)
-
Retrieve the records that match the selection query.
Parameters:
Name Type Argument Description mapper
Object The mapper.
query
Object <optional>
Selection query.
Properties
Name Type Argument Description where
Object <optional>
Filtering criteria.
orderBy
string | Array <optional>
Sorting criteria.
sort
string | Array <optional>
Same as
query.sort
.limit
number <optional>
Limit results.
skip
number <optional>
Offset results.
offset
number <optional>
Same as
query.skip
.opts
Object <optional>
Configuration options.
Properties
Name Type Argument Default Description operators
Object <optional>
Override the default predicate functions for specified operators.
raw
boolean <optional>
false Whether to return a more detailed response object.
runOpts
Object <optional>
Options to pass to r#run.
with
Array.<string> <optional>
[] Relations to eager load.
Returns:
- Type
- Promise
-
getOperator(operator, opts)
-
Resolve the predicate function for the specified operator based on the given options and this adapter's settings.
Parameters:
Name Type Argument Description operator
string The name of the operator.
opts
Object <optional>
Configuration options.
Properties
Name Type Argument Description operators
Object <optional>
Override the default predicate functions for specified operators.
Returns:
The predicate function for the specified operator.
- Type
- *
-
getOpt(opt, opts)
-
Resolve the value of the specified option based on the given options and this adapter's settings.
Parameters:
Name Type Argument Description opt
string The name of the option.
opts
Object <optional>
Configuration options.
Returns:
The value of the specified option.
- Type
- *
-
loadBelongsTo()
-
Load a belongsTo relationship.
Returns:
- Type
- Promise
-
loadHasMany()
-
Load a hasMany relationship.
Returns:
- Type
- Promise
-
loadHasOne()
-
Load a hasOne relationship.
Returns:
- Type
- Promise
-
log()
-
Logging utility method.
-
makeBelongsToForeignKey()
-
Return the foreignKey from the given record for the provided relationship.
Returns:
- Type
- *
-
makeHasManyForeignKey()
-
Return the foreignKey from the given record for the provided relationship.
There may be reasons why you may want to override this method, like when the id of the parent doesn't exactly match up to the key on the child.
Returns:
- Type
- *
-
update(mapper, id, props, opts)
-
Apply the given update to the record with the specified primary key.
Parameters:
Name Type Argument Description mapper
Object The mapper.
id
string | number The primary key of the record to be updated.
props
Object The update to apply to the record.
opts
Object <optional>
Configuration options.
Properties
Name Type Argument Default Description updateOpts
Object <optional>
Options to pass to r#update.
raw
boolean <optional>
false Whether to return a more detailed response object.
runOpts
Object <optional>
Options to pass to r#run.
Returns:
- Type
- Promise
-
updateAll(mapper, props, query, opts)
-
Apply the given update to all records that match the selection query.
Parameters:
Name Type Argument Description mapper
Object The mapper.
props
Object The update to apply to the selected records.
query
Object <optional>
Selection query.
Properties
Name Type Argument Description where
Object <optional>
Filtering criteria.
orderBy
string | Array <optional>
Sorting criteria.
sort
string | Array <optional>
Same as
query.sort
.limit
number <optional>
Limit results.
skip
number <optional>
Offset results.
offset
number <optional>
Same as
query.skip
.opts
Object <optional>
Configuration options.
Properties
Name Type Argument Default Description operators
Object <optional>
Override the default predicate functions for specified operators.
raw
boolean <optional>
false Whether to return a more detailed response object.
runOpts
Object <optional>
Options to pass to r#run.
updateOpts
Object <optional>
Options to pass to r#update.
Returns:
- Type
- Promise
-
updateMany(mapper, records, opts)
-
Update the given records in a single batch.
Parameters:
Name Type Argument Description mapper
Object The mapper.
records
Array.<Object> The records to update.
opts
Object <optional>
Configuration options.
Properties
Name Type Argument Default Description insertOpts
Object <optional>
Options to pass to r#insert.
raw
boolean <optional>
false Whether to return a more detailed response object.
runOpts
Object <optional>
Options to pass to r#run.
Returns:
- Type
- Promise