Class: Repository

Repository(opts)

The Repository class allows to work with documents on a Nuxeo Platform instance.

Cannot directly be instantiated

Constructor

new Repository(opts)

Creates a Repository.

Parameters:
Name Type Description
opts object

The configuration options.

Properties
Name Type Description
nuxeo string

The Nuxeo object linked to this repository.

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
Name Type Attributes Default Description
query string

The query to execute. query or pageProvider must be set.

pageProvider string

The page provider name to execute. query or pageProvider must be set.

queryParams array <optional>

Ordered parameters for the query or page provider.

pageSize number <optional>
0

The number of results per page.

currentPageIndex number <optional>
0

The current page index.

maxResults number <optional>

The expected max results.

sortBy string <optional>

The sort by info.

sortOrder string <optional>

The sort order info.

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