marjory v2.0.1
Marjory SDK
This SDK can be used to write Marjory application and use advanced feature of the Marjory platform.
Installation
You can add the SDK to your project using npm:
npm install marjory
Then you can import the SDK in your application:
import Marjory from "marjory";
The SDK will be automatically initialized with the default configuration when your application will run on Marjory platform.
Usage
App Database (with MongoDB)
Each application have a dedicated database. To manipulate it, you have access to several functions.
Collection access
import Marjory from "marjory";
Marjory.DB.collection("<collection_name>");
Get functions
import Marjory from 'marjory'
const resultFind = await Marjory.DB.collection('<collection_name>').find(...)
const resultFindOne = await Marjory.DB.collection('<collection_name>').findOne(...)
const resultCount = await Marjory.DB.collection('<collection_name>').countDocuments(...)
Insert functions
import Marjory from 'marjory'
const resultInsertOne = await Marjory.DB.collection('<collection_name>').insertOne(...)
const resultInsertMany = await Marjory.DB.collection('<collection_name>').insertMany(...)
If you want to insert multiple documents at the same time, you can use the bulkWrite
function:
import Marjory from "marjory";
const resultBulkWrite = await Marjory.DB.collection(
"<collection_name>"
).bulkWrite([
{ insertOne: { document: { a: 1 } } },
{ insertOne: { document: { a: 2 } } },
{ insertOne: { document: { a: 3 } } },
{ updateOne: { filter: { a: 2 }, update: { $set: { a: 5 } } } },
{ deleteOne: { filter: { c: 1 } } },
{ replaceOne: { filter: { c: 3 }, replacement: { c: 4 } } },
]);
Update functions
import Marjory from 'marjory'
const resultUpdateOne = await Marjory.DB.collection('<collection_name>').updateOne(...)
const resultUpdateMany = await Marjory.DB.collection('<collection_name>').updateMany(...)
const resultFindOneAndUpdate = await Marjory.DB.collection('<collection_name>').findOneAndUpdate(...)
const resultFindOneAndReplace = await Marjory.DB.collection('<collection_name>').findOneAndReplace(...)
const resultReplaceOne = await Marjory.DB.collection('<collection_name>').replaceOne(...)
Delete functions
import Marjory from 'marjory'
const resultDeletetOne = await Marjory.DB.collection('<collection_name>').deleteOne(...)
const resultDeleteMany = await Marjory.DB.collection('<collection_name>').deleteMany(...)
Aggregation functions
import Marjory from 'marjory'
const resultAggregate = await Marjory.DB.collection('<collection_name>').aggregate(...)
Access variables
You can retrieve variables declared inside your Marjory.yml
or deployment.yml
file and configured using marjory configure
command.
import Marjory from "marjory";
const variableValue = await Marjory.VARIABLES.getVariable("<variable_name>");
If this variable is related to an OAuth 2 configuration, the OAuth access_token will be automatically refreshed and returned.
Logger
import Marjory from "marjory";
const detailsObject = {}; // For example stack trace object
await Marjory.LOGGER.trace("message", detailsObject); // equivalent to debug in javascript
await Marjory.LOGGER.info("message", detailsObject);
await Marjory.LOGGER.warn("message", detailsObject);
await Marjory.LOGGER.error("message", detailsObject);
Events
In mostly cases during the webhook and scheduled functions, you will generate events. This method can throw event.
import Marjory from "marjory";
const eventPayload = {};
await Marjory.callEventRepository("<event_name>", eventPayload);
HTTP Request (using embedded axios) - DEPRECATED
⚠️ This feature is deprecated. You should rather use your own HTTP client.
import Marjory from 'marjory'
const response = await Marjory.axios({
method: 'GET | POST | PUT | DELETE',
url: '',
baseUrl: '',
headers: {},
body: {},
...
})
Access context information
⚠️ You should rather use the Access variables feature to access context information.
import Marjory from "marjory";
// Access to the node identifier
const nodeId = Marjory.nodeId;
// Access to the authorization token
// that's allow you to be authenticate at each
// Marjory service (most case : file server)
const authorizationToken = Marjory.authorizationToken;
// Access to the invocation id of the running workflow
const invocationId = Marjory.invocationId;
// Access to the tenant name
// For example : if your tenant url is https://johndoe.marjory.io
// Marjory.realm will return "johndoe"
const tenant = Marjory.realm;
Issues
If you have any issue, please contact us at support@marjory.io
7 days ago
19 days ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
6 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
10 months ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago