New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

marjory

Package Overview
Dependencies
Maintainers
1
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marjory

marjory sdk

latest
npmnpm
Version
3.4.1
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 23 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts