hemera-store
v2.0.0
Published
This is a store interface for Hemera to be interoperable with most database interfaces
Downloads
85
Readme
Hemera-store package
Simple API to be interoperable with most database interfaces.
Interface
Provide a unique pattern set for all common api methods. We had to choose for some conventions across document and table oriented stores.
| Table-oriented | Document-oriented | Convention | | -------------- | ----------------- | -------------- | | Database | Database | Database | | Collection | Collection | Collection |
create
The pattern is:
topic
: is the store name to publish to<name>-store
cmd
: is the command to executecreate
collection
: the name of the table or collectionstring
data
: the data which represent the entity to createobject
orArray<object>
Example:
hemera.act(
{
topic: 'sql-store',
cmd: 'create',
collection: 'product',
data: {
name: 'tomato'
}
},
function(err, resp) {}
)
update
The pattern is:
topic
: is the store name to publish to<name>-store
cmd
: is the command to executeupdate
collection
: the name of the table or collectionstring
data
: the data which represent the entity to updateobject
query
: the search criteriaobject
Example:
hemera.act(
{
topic: 'sql-store',
cmd: 'update',
collection: 'product',
query: {},
data: {
name: 'tomato'
}
},
function(err, resp) {}
)
updateById
The pattern is:
topic
: is the store name to publish to<name>-store
cmd
: is the command to executeupdateById
collection
: the name of the table or collectionstring
data
: the data which represent the entity to createobject
id
: the primary identifier of your entitystring
ornumber
Example:
hemera.act(
{
topic: 'sql-store',
cmd: 'updateById',
id: 1,
collection: 'product',
data: {
name: 'tomato'
}
},
function(err, resp) {}
)
find
The pattern is:
topic
: is the store name to publish to<name>-store
cmd
: is the command to executefind
collection
: the name of the table or collectionstring
query
: the search criteriaobject
options
: the search criteriaobject
(optional)limit
: maximum items to fetchinteger
offset
: the offsetinteger
orderBy
: the offsetarray<string>
orstring
ormap<string, int>
fields
: the projection settingsarray<string>
ormap<string, int>
Example:
hemera.act(
{
topic: 'sql-store',
cmd: 'find',
collection: 'product',
query: {}
},
function(err, resp) {}
)
findById
The pattern is:
topic
: is the store name to publish to<name>-store
cmd
: is the command to executefindById
collection
: the name of the table or collectionstring
id
: the primary identifier of your entitystring
ornumber
Example:
hemera.act(
{
topic: 'sql-store',
cmd: 'findById',
id: 1,
collection: 'product'
},
function(err, resp) {}
)
remove
The pattern is:
topic
: is the store name to publish to<name>-store
cmd
: is the command to executeremove
collection
: the name of the table or collectionstring
query
: the search criteriaobject
Example:
hemera.act(
{
topic: 'sql-store',
cmd: 'remove',
collection: 'product',
query: {}
},
function(err, resp) {}
)
removeById
The pattern is:
topic
: is the topic to publish tosql-store
cmd
: is the command to executeremoveById
collection
: the name of the table or collectionstring
id
: the primary identifier of your entitystring
ornumber
Example:
hemera.act(
{
topic: 'sql-store',
cmd: 'removeById',
id: 1,
collection: 'product'
},
function(err, resp) {}
)
replace
The pattern is:
topic
: is the store name to publish to<name>-store
cmd
: is the command to executereplace
collection
: the name of the table or collectionstring
data
: the data which represent the entity to replaceobject
query
: the search criteriaobject
Example:
hemera.act(
{
topic: 'sql-store',
cmd: 'replace',
collection: 'product',
query: {},
data: {
name: 'tomato'
}
},
function(err, resp) {}
)
replaceById
The pattern is:
topic
: is the store name to publish to<name>-store
cmd
: is the command to executereplaceById
collection
: the name of the table or collectionstring
data
: the data which represent the entity to updateobject
id
: the primary identifier of your entitystring
ornumber
Example:
hemera.act(
{
topic: 'sql-store',
cmd: 'replaceById',
id: 1,
collection: 'product',
data: {
name: 'tomato'
}
},
function(err, resp) {}
)
exists
The pattern is:
topic
: is the store name to publish to<name>-store
cmd
: is the command to executeexists
collection
: the name of the table or collectionstring
query
: the search criteriaobject
Example:
hemera.act(
{
topic: 'sql-store',
cmd: 'exists',
collection: 'product',
query: {}
},
function(err, resp) {}
)
count
The pattern is:
topic
: is the store name to publish to<name>-store
cmd
: is the command to executecount
collection
: the name of the table or collectionstring
query
: the search criteriaobject
Example:
hemera.act(
{
topic: 'sql-store',
cmd: 'count',
collection: 'product',
query: {}
},
function(err, resp) {}
)