Socket
Socket
Sign inDemoInstall

@e22m4u/node-repository-mongodb-adapter

Package Overview
Dependencies
218
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @e22m4u/node-repository-mongodb-adapter

MongoDB адаптер для @e22m4u/node-repository


Version published
Maintainers
1
Created

Readme

Source

@e22m4u/node-repository-mongodb-adapter

MongoDB адаптер для @e22m4u/node-repository

Установка

npm install @e22m4u/node-repository-mongodb-adapter

требует пакет node-repository

Параметры

Все указанные параметры опциональны:

названиезначение по умолчанию
protocol'mongodb'
host'127.0.0.1'
port27017
database'database'
usernameundefined
passwordundefined

Пример:

import {Schema} from '@e22m4u/node-repository';

const schema = new Schema();

// объявление источника
schema.defineDatasource({
  name: 'myMongo', // название источника
  adapter: 'mongodb', // имя адаптера
  // параметры
  host: '192.128.0.2',
  port: 27017,
})

// объявление модели
schema.defineModel({
  name: 'user', // название модели
  datasource: 'myMongo', // используемый источник
  properties: { // поля модели
    name: 'string',
    surname: 'string',
  },
});

// получаем репозиторий по названию модели и создаем запись
const userRep = schema.getRepository('user');
const user = await userRep.create({name: 'John', surname: 'Doe'});

console.log(user);
// {
//   id: '64f3454e5e0893c13f9bf47e',
//   name: 'John',
//   surname: 'Doe',
// }

Тесты

Запуск контейнера mongodb_c скриптом setup.sh

./setup.sh

Выполнение тестов

npm run test

Лицензия

MIT

Keywords

FAQs

Last updated on 22 Sep 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc