Class: Repository

Repository

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.

Source:
Example
var Nuxeo = require('nuxeo')
var nuxeo = new Nuxeo({
 baseUrl: 'http://localhost:8080/nuxeo',
 auth: {
   username: 'Administrator',
   password: 'Administrator',
 }
});
nuxeo.repository('default')
  .fetch('/default-domain').then((res) => {
    // res.uid !== null
    // res.type === 'Domain'
  }).catch(error => throw new Error(error));

Methods

create(parentRef, doc, opts) → {Promise}

Creates a document given a document ref.

Parameters:
Name Type Description
parentRef string

The parent document ref. A path if starting with '/', otherwise and id.

doc object

The document to be created.

opts object

Options overriding the ones from the Request object.

Source:
Returns:

A Promise object resolved with the created Document.

Type
Promise

delete(ref, opts) → {Promise}

Deletes a document given a document ref.

Parameters:
Name Type Description
ref string

The document ref. A path if starting with '/', otherwise and id.

opts object

Options overriding the ones from the Request object.

Source:
Returns:

A Promise object resolved with the result of the DELETE request.

Type
Promise

fetch(ref, opts) → {Promise}

Fetches a document given a document ref.

Parameters:
Name Type Description
ref string

The document ref. A path if starting with '/', otherwise and id.

opts object

Options overriding the ones from the Request object.

Source:
Returns:

A Promise object resolved with the Document.

Type
Promise

update(doc, opts) → {Promise}

Updates a document. Assumes that the doc object has an uid field.

Parameters:
Name Type Description
doc object

The document to be updated.

opts object

Options overriding the ones from the Request object.

Source:
Returns:

A Promise object resolved with the updated Document.

Type
Promise