This package has been deprecated

Author message:

1.0.1

mongoose-embedded-document

1.0.2 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i mongoose-embedded-document

Weekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • goodeggs-admin
  • asalant