Storage

fetch()

Updates local class, function returns Promise.

const service = new Mixapp.Service([options])
service.workplaces.get('workplace')
    .then(workplace => {
        return workplace.storages.get('storage');
    })
    .then(storage => {
        return storage.fetch();
    })
    .catch(err => {})

update(data)

Updates storage settings, function returns Promise.

const service = new Mixapp.Service([options])
service.workplaces.get('workplace')
    .then(workplace => {
        return workplace.storages.get('storage');
    })
    .then(storage => {
        return storage.update({});
    })
    .catch(err => {})

Data parameter contains storage settings that are being updated.

Please

note This method has been created to update settings that will be available in the next version.

remove()

Deletes the storage, function returns Promise.

const service = new Mixapp.Service([options])
service.workplaces.get('workplace')
    .then(workplace => {
        return workplace.storages.get('storage');
    })
    .then(storage => {
        return storage.remove();
    })
    .catch(err => {})

getIndexes()

Retrieves list of storage indexes, function returns Promise.

const service = new Mixapp.Service([options])
service.workplaces.get('workplace')
    .then(workplace => {
        return workplace.storages.get('storage');
    })
    .then(storage => {
        return storage.getIndexes();
    })
    .catch(err => {})

createIndex(index)

Creates an index, function returns Promise.

const service = new Mixapp.Service([options])
service.workplaces.get('workplace')
    .then(workplace => {
        return workplace.storages.get('storage');
    })
    .then(storage => {
        return storage.createIndex({
            "name": "myindex",
            "key": ["-field1"],
        });
    })
    .catch(err => {})

Index parameter contains parameters of the index created.

Name Type Description
name String Index name
key Array Names of fields being indexed (array)

removeIndex(name)

Deletes the index, function returns Promise.

const service = new Mixapp.Service([options])
service.workplaces.get('workplace')
    .then(workplace => {
        return workplace.storages.get('storage');
    })
    .then(storage => {
        return storage.removeIndex('myindex');
    })
    .catch(err => {})
Name Type Description
name String Name of the index

getDocuments(protocol)

Retrieves list of documents, function returns Promise.

const service = new Mixapp.Service([options])
service.workplaces.get('workplace')
    .then(workplace => {
        return workplace.storages.get('storage');
    })
    .then(storage => {
        return storage.getDocuments({});
    })
    .catch(err => {})
Name Type Description
protocol Object см. Storage protocol

createDocument(protocol)

Creates a document, function returns Promise.

const service = new Mixapp.Service([options])
service.workplaces.get('workplace')
    .then(workplace => {
        return workplace.storages.get('storage');
    })
    .then(storage => {
        return storage.createDocument({});
    })
    .catch(err => {})
Name Type Description
protocol Object см. Storage protocol

updateDocuments(protocol)

Updates documents, function returns Promise.

const service = new Mixapp.Service([options])
service.workplaces.get('workplace')
    .then(workplace => {
        return workplace.storages.get('storage');
    })
    .then(storage => {
        return storage.updateDocuments({});
    })
    .catch(err => {})
Name Type Description
protocol Object см. Storage protocol

removeDocuments(protocol)

Deletes documents, function returns Promise.

const service = new Mixapp.Service([options])
service.workplaces.get('workplace')
    .then(workplace => {
        return workplace.storages.get('storage');
    })
    .then(storage => {
        return storage.removeDocuments({});
    })
    .catch(err => {})
Name Type Description
protocol Object см. Storage protocol

countDocuments(protocol)

Requests number of documents, function returns Promise.

const service = new Mixapp.Service([options])
service.workplaces.get('workplace')
    .then(workplace => {
        return workplace.storages.get('storage');
    })
    .then(storage => {
        return storage.countDocuments({});
    })
    .catch(err => {})
Name Type Description
protocol Object см. Storage protocol