You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@feedbackfruits/east-mongo

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@feedbackfruits/east-mongo

mongodb adapter for east (node.js database migration tool)

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
0
Created
Source

east mongo

[!NOTE] This is a fork from https://github.com/okv/east-mongo, continued in Typescript with current versions of MongoDB

Mongodb adapter for east, a Node.js database migration tool, which uses the mongodb native driver to perform migrations.

All executed migrations names will be stored at _migrations collection in the current database, where the _id for each document is the name of the executed migration. A pre-connected instance of MongoClient will be passed in to these migrations.

east-mongo also provides a template for use with migrations at lib/migrationTemplates/async.js.

This default migration template will be used if template is not set. To override this behaviour and provide your own template, set template in your .eastrc file to the path of your template file:

	module.exports = {
		template: require.resolve('east-mongo/lib/migrationTemplates/async.js')
	}

or in Typescript

export default {
  template: require.resolve('east-mongo/lib/migrationTemplates/async.ts')
}

npm

Node.js compatibility & MongoDB Driver compatibility

east-mongo supports current, active and maintenance versions of node.js: https://nodejs.org/en/about/previous-releases Currently this means this package is tested against versions 18, 20 and 22.

For the MongoDB drivers, we follow language compatibility matrix from MongoDB: https://www.mongodb.com/docs/drivers/node/current/compatibility/#language-compatibility This currently means the minimum supported version is 4.x

Installation

mongodb adapter requires mongodb package as peer dependency, so you should install it manually along side with east:

npm install east @feedbackfruits/east-mongo mongodb
# or 
yarn add east @feedbackfruits/east-mongo mongodb

Usage

Sample .eastrc content:

{
	"adapter": "@feedbackfruits/east-mongo",
	"url": "mongodb://localhost:27017/test",
	"options": {
		"server": {
			"socketOptions": {
				"socketTimeoutMS": 3600000
			}
		}
	}
}

Alternatively, pass in the options through the CLI:

east migrate --adapter east-mongo --url $MONGODB_URI
# or, to run TS migrations
yarn add -DE tsx
tsx node_modules/east/bin/east.js migrate --adapter east-mongo --url $MONGODB_URI --migration-extension ts

Where url is url of database which you want to migrate (in mongodb native url connection format) and options is optional settings (see connect method specification).

Migration files created with default template that comes with adapter will look like:

import type { MongoClient } from 'mongodb';

exports.tags = [];

exports.migrate = async (client: MongoClient) => {
  // Migration definition
};

exports.rollback = async (client: MongoClient) => {
  // Rollback definitions
};

See east cli or library usage for more details.

License

MIT

Keywords

database

FAQs

Package last updated on 26 Jun 2024

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