new Database(options)
The database instance
Parameters:
Name |
Type |
Description |
options |
object
|
The options
Properties
Name |
Type |
Description |
name |
string
|
The name |
host |
string
|
The hostname |
port |
number
|
The port |
credentials |
object
|
The user credentials
Properties
Name |
Type |
Description |
username |
string
|
The username |
password |
string
|
The password |
|
|
Properties:
Name |
Type |
Description |
options |
object
|
The options
Properties
Name |
Type |
Description |
name |
string
|
The name |
host |
string
|
The hostname |
port |
number
|
The port |
credentials |
object
|
The user credentials
Properties
Name |
Type |
Description |
username |
string
|
The username |
password |
string
|
The password |
|
|
mdb |
object
|
The mongodb driver database instance |
collections |
object
|
The collections configured |
cache |
Cache
|
The Cache provider |
events |
object
|
The global events configured |
Methods
Configure the proxy.
Parameters:
connect(cb)
Connect to the database.
Parameters:
createApi(reqopt, resopt, internalopt) → {Api}
Create an api for the database
Parameters:
Name |
Type |
Attributes |
Description |
req |
HttpRequest
|
<optional>
|
The http request object |
res |
HttpResponse
|
<optional>
|
The http response object |
internal |
boolean
|
<optional>
|
Whether the store is in internal mode or not |
Returns:
-
Type
-
Api
createStore(name, reqopt, resopt, internalopt) → {Store}
Create a store for a collection.
Parameters:
Name |
Type |
Attributes |
Description |
name |
string
|
|
The collection name |
req |
HttpRequest
|
<optional>
|
The http request object |
res |
HttpResponse
|
<optional>
|
The http response object |
internal |
boolean
|
<optional>
|
Whether the store is in internal mode or not |
Returns:
-
Type
-
Store
drop(cb)
Drop the database.
Parameters:
Name |
Type |
Description |
cb |
Database~dropCallback
|
The callback function |
handle(route, next, cb)
Handle an http incoming request
Parameters:
Type Definitions
connectCallback(err, res)
Parameters:
Name |
Type |
Description |
err |
Exception
|
The exception object |
res |
object
|
The database instance |
handleCallback(err, res)
Parameters:
Name |
Type |
Description |
err |
Exception
|
The exception object |
res |
string
|
The results |
handleNextCallback()
routeOptions(method, collection, path, query, dataopt, reqopt, resopt)
Parameters:
Name |
Type |
Attributes |
Description |
method |
string
|
|
The http method name |
collection |
string
|
|
The collection name |
path |
string
|
|
The path of the collection query (emit the collection name) |
query |
string
|
|
The stringified query |
data |
object
|
<optional>
|
The posted data (if any) |
req |
HttpRequest
|
<optional>
|
The http request object |
res |
HttpResponse
|
<optional>
|
The http response object |