Constructor
new Repository(opts)
Creates a Repository.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
opts |
object | The configuration options. Properties
|
- Source:
Example
var Nuxeo = require('nuxeo')
var nuxeo = new Nuxeo({
baseURL: 'http://localhost:8080/nuxeo',
auth: {
method: 'basic',
username: 'Administrator',
password: 'Administrator'
}
});
nuxeo.repository('default')
.fetch('/default-domain')
.then(function(res) {
// res.uid !== null
// res.type === 'Domain'
})
.catch(function(error) {
throw new Error(error);
});
Methods
create(parentRef, doc, optsopt) → {Promise}
Creates a document.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
parentRef |
string | The parent document ref. A path if starting with '/', otherwise and id. |
|
doc |
object | The document to be created. |
|
opts |
object |
<optional> |
Options overriding the ones from this object. |
- Source:
Returns:
A Promise object resolved with the created Document.
- Type
- Promise
delete(ref, optsopt) → {Promise}
Deletes a document given a document ref.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ref |
string | The document ref. A path if starting with '/', otherwise and id. |
|
opts |
object |
<optional> |
Options overriding the ones from this object. |
- Source:
Returns:
A Promise object resolved with the result of the DELETE request.
- Type
- Promise
fetch(ref, optsopt) → {Promise}
Fetches a document given a document ref.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ref |
string | The document ref. A path if starting with '/', otherwise and id. |
|
opts |
object |
<optional> |
Options overriding the ones from this object. |
- Source:
Returns:
A Promise object resolved with the Document.
- Type
- Promise
query(queryOpts, optsopt) → {Promise}
Performs a query returning documents.
Named parameters can be set in the queryOpts
object, such as
{ query: ..., customParam1: 'foo', anotherParam: 'bar'}
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
queryOpts |
object | The query options. Properties
|
||||||||||||||||||||||||||||||||||||||||||||||
opts |
object |
<optional> |
Options overriding the ones from this object. |
- Source:
Returns:
A Promise object resolved with the response where the entries are replaced
with Document objetcs.
- Type
- Promise
update(doc, optsopt) → {Promise}
Updates a document. Assumes that the doc object has an uid field.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
doc |
object | The document to be updated. |
|
opts |
object |
<optional> |
Options overriding the ones from this object. |
- Source:
Returns:
A Promise object resolved with the updated Document.
- Type
- Promise