3.4.1 • Published 6 months ago

marjory v3.4.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

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";

const myCollection = await Marjory.Db.collection("<collection_name>");

Get functions

import Marjory from 'marjory';

const myCollection = await Marjory.Db.collection("<collection_name>");

const resultFind = await myCollection.find(...);
const resultFindOne = await myCollection.findOne(...);
const resultCount = await myCollection.countDocuments(...);

Insert functions

import Marjory from 'marjory';

const myCollection = await Marjory.Db.collection("<collection_name>");

const resultInsertOne = await myCollection.insertOne(...);
const resultInsertMany = await myCollection.insertMany(...);

If you want to insert multiple documents at the same time, you can use the bulkWrite function:

import Marjory from "marjory";

const myCollection = await Marjory.Db.collection("<collection_name>");

const resultBulkWrite = await myCollection.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 myCollection = await Marjory.Db.collection("<collection_name>");

const resultUpdateOne = await myCollection.updateOne(...)
const resultUpdateMany = await myCollection.updateMany(...)
const resultFindOneAndUpdate = await myCollection.findOneAndUpdate(...)
const resultFindOneAndReplace = await myCollection.findOneAndReplace(...)
const resultReplaceOne = await myCollection.replaceOne(...)

Delete functions

import Marjory from 'marjory';

const myCollection = await Marjory.Db.collection("<collection_name>");

const resultDeletetOne = await myCollection.deleteOne(...);
const resultDeleteMany = await myCollection.deleteMany(...);

Aggregation functions

import Marjory from 'marjory';

const myCollection = await Marjory.Db.collection("<collection_name>");

const resultAggregate = await myCollection.aggregate(...);

Access variables

You can retrieve variables declared inside your deployment.yml file and configured using marjory configure command.

import Marjory from "marjory";

const variableValue = Marjory.variables["<variable_name>"];

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 webservice and scheduled functions, you will generate events. This method can throw event.

import Marjory from "marjory";

const eventPayload = {};
await Marjory.Events.send("<event_name>", eventPayload);

Access context information

You can retrieve context information of the execution of you function.

import Marjory from "marjory";

const contextValue = Marjory.context["<context_property>"];

Files

You can use the SDK to upload and download files.

Upload Files

import Marjory from "marjory";

const buffer = Buffer.from("<file_content>", "utf-8");
await Marjory.sdk.Files.upload("<file_name>", buffer);

Download Files

import Marjory from "marjory";

const buffer = Buffer.from("<file_content>", "utf-8");
const myFile = await Marjory.sdk.Files.upload("<file_name>", buffer);

const myBuffer = await Marjory.sdk.Files.download(myFile);

Issues

If you have any issue, please contact us at support@marjory.io

3.4.0

7 months ago

3.4.1

6 months ago

3.3.6

9 months ago

3.3.5-beta.2

9 months ago

3.3.5-beta.1

9 months ago

3.3.5

9 months ago

3.3.4-beta.1

9 months ago

3.3.1

10 months ago

3.3.0

10 months ago

3.3.4

9 months ago

3.3.3

10 months ago

3.3.2

10 months ago

3.2.1

1 year ago

3.2.0

1 year ago

3.1.1

1 year ago

2.0.1

1 year ago

3.1.0

1 year ago

2.0.1-beta.10

1 year ago

3.0.11

1 year ago

3.0.10

1 year ago

3.0.8

1 year ago

3.0.7

1 year ago

3.0.9

1 year ago

3.0.6

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.5

1 year ago

3.0.0

1 year ago

2.0.0-beta.9

2 years ago

1.6.3

2 years ago

1.6.2

2 years ago

1.6.1

2 years ago

2.0.0-beta.8

2 years ago

2.0.0-beta.7

2 years ago

2.0.0-beta.6

2 years ago

2.0.0-beta.5

2 years ago

2.0.0-beta.4

2 years ago

2.0.0-beta.3

2 years ago

2.0.0-beta.2

2 years ago

2.0.0-beta.1

2 years ago

1.6.0

2 years ago

1.6.0-beta.1

2 years ago

1.5.0

2 years ago

1.5.0-beta.2

2 years ago

1.5.0-beta.22

2 years ago

1.5.0-beta.21

2 years ago

1.5.0-beta.20

2 years ago

1.5.0-beta.8

2 years ago

1.5.0-beta.7

2 years ago

1.5.0-beta.9

2 years ago

1.5.0-beta.4

2 years ago

1.5.0-beta.3

2 years ago

1.5.0-beta.6

2 years ago

1.5.0-beta.5

2 years ago

1.5.0-beta.19

2 years ago

1.5.0-beta.18

2 years ago

1.5.0-beta.17

2 years ago

1.5.0-beta.16

2 years ago

1.5.0-beta.15

2 years ago

1.5.0-beta.14

2 years ago

1.5.0-beta.13

2 years ago

1.5.0-beta.12

2 years ago

1.5.0-beta.11

2 years ago

1.5.0-beta.10

2 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.12

3 years ago

1.2.10

3 years ago

1.2.11

3 years ago

1.2.0

4 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.9

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.16

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.13

4 years ago

1.1.18

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.5

4 years ago

1.0.51

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago