Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-embedded-document

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-embedded-document

A Mongoose plugin to provide support for embedding single documents.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

mongoose-embedded-document

A Mongoose plugin to provide support for embedding single documents.

NPM version Build Status MIT License

Usage

npm install mongoose-embedded-document
var embeddedDoc = require 'mongoose-embedded-document


embeddedSchema = new mongoose.Schema name: String
Embedded = mongoose.model('Embedded', embeddedSchema)

schema = new mongoose.Schema deep: {}
schema.plugin embeddedDoc, path: 'embedded', ref: 'Embedded', required: true
schema.plugin embeddedDoc, path: 'deep.embedded', ref: 'Embedded'
Parent = mongoose.model('Parent', schema)

parent = new Parent embedded: new Embedded(name: 'My Name')
parent.deep.embedded = new Embedded(name: 'My Deep Name')

console.log parent.embedded.name      # Logs 'My Name'
console.log parent.deep.embedded.name # Logs 'My Deep Name'

Known Issues

This plugin uses Schema.Types.Mixed for the type of the embedded document. This means that the parent schema does not know the types of the attributes of the embedded document. This can be an issue when you are used to relying on Mongoose's type casting in queries for attributes of type ObjectId and Date in particular.

Contributing

Please follow our Code of Conduct when contributing to this project.

$ git clone https://github.com/goodeggs/mongoose-embedded-document && cd mongoose-embedded-document
$ npm install
$ npm test

Module scaffold generated by generator-goodeggs-npm.

Keywords

FAQs

Package last updated on 17 Sep 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