elemental-lowcode

Elemental lowcode development platform.

View the Project on GitHub PhilipSkinner/elemental-lowcode

Back to Services

Storage Service

The storage service allows you to access data types defined within the storage system. It provides the following methods:

Each of these methods is covered in more detail below.

detailCollection

Parameters:

Returns the JSON response from the relevant .details endpoint on the storage service. More details on this response payload can be found within the storage system documentation.

This method returns a Promise which can resolve or reject. You must make sure to handle rejections correctly.

This can be called from within a controller like so:

module.exports = {
	events : {
		load : (event) => {
			return this.storageService.detailCollection(
				"books"
			).then((result) => {

			}).catch((err) => {

			});
		}
	}
};

getList

Parameters:

Returns a paginated list of entities from the named collection. More details on this response payload can be found within the storage system documentation.

Filters can be applied to the entities to only include items that have certain values. Filters are based upon the JSON path of the value within the entity and match (equality) against a single value.

This method returns a Promise which can resolve or reject. You must make sure to handle rejections correctly.

This can be called from within a controller like so:

module.exports = {
	events : {
		myEvent : (event) => {
			return this.storageService.getList(
				`authors/${event.authorId}/books`,
				1,
				10,
				{
					"$.rating" : "10"
				}
			).then((result) => {

			}).catch((err) => {

			});
		}
	}
};

getEntity

Parameters:

Returns a single entity from the named collection. More details on this response payload can be found within the storage system documentation.

This method returns a Promise which can resolve or reject. You must make sure to handle rejections correctly.

This can be called from within a controller like so:

module.exports = {
	events : {
		myEvent : (event) => {
			return this.storageService.getEntity(
				`authors/${event.authorId}/books`,
				"16aeb990-4f40-4060-892c-bebe9456de3f"
			).then((result) => {

			}).catch((err) => {

			});
		}
	}
};

createEntity

Parameters:

Creates a new entity within the named collection. More details on this response payload can be found within the storage system documentation.

This method returns a Promise which can resolve or reject. You must make sure to handle rejections correctly. This promise will return the newly created object as the result.

This can be called from within a controller like so:

module.exports = {
	events : {
		myEvent : (event) => {
			return this.storageService.createEntity(
				`authors/${event.authorId}/books`,
				{
					hello : "world"
				}
			).then((result) => {

			}).catch((err) => {

			});
		}
	}
};

updateEntity

Parameters:

Updates an entity within the collection. More details on this response payload can be found within the storage system documentation.

This method returns a Promise which can resolve or reject. You must make sure to handle rejections correctly.

This can be called from within a controller like so:

module.exports = {
	events : {
		myEvent : (event) => {
			return this.storageService.updateEntity(
				`authors/${event.authorId}/books`,
				"16aeb990-4f40-4060-892c-bebe9456de3f",
				{
					hello : "world"
				}
			).then((result) => {

			}).catch((err) => {

			});
		}
	}
};

patchEntity

Parameters:

Partially updates an entity within the collection. More details on this response payload can be found within the storage system documentation.

This method returns a Promise which can resolve or reject. You must make sure to handle rejections correctly.

This can be called from within a controller like so:

module.exports = {
	events : {
		myEvent : (event) => {
			return this.storageService.updateEntity(
				`authors/${event.authorId}/books`,
				"16aeb990-4f40-4060-892c-bebe9456de3f",
				{
					hello : "world"
				}
			).then((result) => {

			}).catch((err) => {

			});
		}
	}
};

deleteEntity

Parameters:

Deletes an entity from the named collection. More details on this response payload can be found within the storage system documentation.

This method returns a Promise which can resolve or reject. You must make sure to handle rejections correctly.

This can be called from within a controller like so:

module.exports = {
	events : {
		myEvent : (event) => {
			return this.storageService.deleteEntity(
				`authors/${event.authorId}/books`,
				"16aeb990-4f40-4060-892c-bebe9456de3f"
			).then((result) => {

			}).catch((err) => {

			});
		}
	}
};