New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

speck-sequelize-repository

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

speck-sequelize-repository

Repositories using Speck

  • 1.1.0-alpha
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Speck Sequelize Repository - Create repositories handle Sequelize models with Speck.

Build Status

This package let you use Speck with repositories to handle Sequelize models.

Installing

$ npm install speck-sequelize-repository

Examples

Sample Repository
const { Repository } = require('speck-sequelize-repository')

const { MySequelizeModel } = require('./models')
const MyModelMap = require('./modelMaps/MyModelMap')

const MyModelRepository = {
  customQuery ({ someField }) {
    return this.findOneByCriterias({ someField })
  }
}

module.exports = Repository.for(MySequelizeModel, MyModelMap, MyModelRepository)

Sample Mapper

Creates a mapper like in object-mapper:

const { Mapper } = require('speck-sequelize-repository')

const map = {
  toEntity: {
    'someField': 'someField'
  },
  toDatabase: {
    'someField': 'someField'
  }
}

module.exports = new Mapper(Object, map)

Auto Mapper

Creates a Mapper without specifying manually the map fields:

  const { AutoMapper } = require('speck-sequelize-repository')
  const mapper = new AutoMapper(someSpeckEntity)

The map fields will be automatically created from a speck entity. Note: entity relationships will have opinionated naming, example: entity.relationship will expect on database a relationship table with relationshipId field.

You can also override some of the automatically generated fields naming, or exclude entity properties from map on AutoMapper constructor:

  const mapper = new AutoMapper(someSpeckEntity, {
     override: {
       entityField: 'otherFieldName',
       entityRelationshipField: 'otherTableName.otherFieldName'
     },
     exclude: ['someEntityProperty']
  )

Keywords

FAQs

Package last updated on 26 Jan 2019

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc