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

json-schema-models

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-models

json schema based models

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by25%
Maintainers
1
Weekly downloads
 
Created
Source

json-schema-models build status

Data models for mongodb using json schema to define polymorphic schemas to be used with mongodb. Internally modules use z-schema for json validation and mongodb native driver to connect to db.

Not currently fit for public consumption

API
new jsonSchemaModels(options);

options object must contain the following properties

  • mongo

    • name - mongodb name
    • url - mongodb url string (host and port)
    • options - mongodb connection options
  • schema

    • formats - an object with keys being name of format to register and value being the custom function to register for z-schema validation
  • validator - an object created by z-schema constructor function

.start(callback)
  • method to validate the schemas

    params
    • callback with error, result signature - error will show if any schemas have failed validation and result is an object containing the raw mognodb db handle from connection and an object containing handles to each model with keys beign name of model and value being the handle.
.stop(callback)
  • method to close connections and clean-up for server closedown

    params
    • optional callback with no signature
.buildIndexes(callback)
  • method to build indexes based on schema definition

    params
    • callback with err signature
Todo
  • Add json-schema validation to model insert, insertMany and update methods
  • Add lifecycle hooks for methods that are defined on schema definitions
  • Intergrate dropAllIndexes method
  • Handle multi-tenant database semantics
  • Switch to promises, generators or async await instead of neo-async dependency
  • Add query parser for mongodb
  • Argument checker for api rather than hardcoding incoming parameters to collection / record objects
  • Add interface to models as well as low-level collection objects

FAQs

Package last updated on 26 Oct 2015

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