All Projects → mongodb-js → Mongoose Autopopulate

mongodb-js / Mongoose Autopopulate

Licence: apache-2.0
Always populate() certain fields in your mongoose schemas

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Mongoose Autopopulate

Fastify Api
A blazing fast REST APIs with Node.js, MongoDB, Fastify and Swagger.
Stars: ✭ 138 (-18.82%)
Mutual labels:  mongoose
Node Express Mongo Api
Starter project for a REST API with Node.js, Express & MongoDB 🔋
Stars: ✭ 148 (-12.94%)
Mutual labels:  mongoose
Nauth Restful Api
Node.js+Mongoose的RestfulApi的用户token权限验证(just a demo)
Stars: ✭ 155 (-8.82%)
Mutual labels:  mongoose
Api Query Params
Convert URL query parameters to MongoDB queries
Stars: ✭ 141 (-17.06%)
Mutual labels:  mongoose
Node Express Mongoose Passport Jwt Rest Api Auth
Node, express, mongoose, passport and JWT REST API authentication example
Stars: ✭ 146 (-14.12%)
Mutual labels:  mongoose
React Express Blog Demo
🔥 React full stack+Express+Mongo implementation blog website tutorial 🌚
Stars: ✭ 1,857 (+992.35%)
Mutual labels:  mongoose
Nodejs Rest Api Project Structure Express
Nodejs project structure practices for building RESTful APIs using Express framework and MongoDB.
Stars: ✭ 134 (-21.18%)
Mutual labels:  mongoose
Nestjs Mongoose Crud
Nest.js crud module for mongoose models without `nestjsx/crud`
Stars: ✭ 164 (-3.53%)
Mutual labels:  mongoose
Koa Restful Boilerplate
Koa 2 RESTful API boilerplate
Stars: ✭ 146 (-14.12%)
Mutual labels:  mongoose
Next Graphql Blog
🖊 A Blog including a server and a client. Server is built with Node, Express & a customized GraphQL-yoga server. Client is built with React, Next js & Apollo client.
Stars: ✭ 152 (-10.59%)
Mutual labels:  mongoose
Gindex V4
A Vue Js Based G Index with Improved Dark Mode, Search and Video Player
Stars: ✭ 143 (-15.88%)
Mutual labels:  mongoose
Forest Express Mongoose
🌱 Express/Mongoose Liana for Forest Admin
Stars: ✭ 145 (-14.71%)
Mutual labels:  mongoose
Amazona
Build Ecommerce Like Amazon By MERN Stack
Stars: ✭ 152 (-10.59%)
Mutual labels:  mongoose
Express Oas Generator
OpenAPI (Swagger) specification generator for ExpressJS applications
Stars: ✭ 138 (-18.82%)
Mutual labels:  mongoose
Mongoose Typescript Example
Stars: ✭ 156 (-8.24%)
Mutual labels:  mongoose
Node Elm
基于 node.js + Mongodb 构建的后台系统
Stars: ✭ 11,224 (+6502.35%)
Mutual labels:  mongoose
Node Easy Notes App
A simple Note-Taking app built using Node.js, Express and Mongoose
Stars: ✭ 148 (-12.94%)
Mutual labels:  mongoose
Ecommerce Site Template
A beautiful e-commerce template powered by React, Redux and other modern web tech.
Stars: ✭ 167 (-1.76%)
Mutual labels:  mongoose
Frisky
🍿 Open Source GraphQL API for Online Shows
Stars: ✭ 161 (-5.29%)
Mutual labels:  mongoose
Nodejs
This project provides Scala.js type-safe bindings for Node.js (current) v8.7.0 and LTS v6.11.4 APIs. The platform supports MEAN (MongoDB, Express, AngularJs, NodeJS), Cassandra, MySQL and many other npm projects.
Stars: ✭ 152 (-10.59%)
Mutual labels:  mongoose

mongoose-autopopulate

Always populate() certain fields in your mongoose schemas

Build Status Coverage Status

Read the docs here.

Note: This plugin will only work with mongoose >= 4.0. Do NOT use this plugin with mongoose 3.x. You have been warned.

Note: population is a powerful feature, but it has limitations and helps you get away with poor schema design. In particular, it is usually bad MongoDB schema design to include arrays that grow without bound in your documents. Do not include a constantly-growing array of ObjectIds in your schema - your data will become unwieldy as the array grows and you will eventually hit the 16 MB document size limit. In general, think carefully when designing your schemas.

Usage

The mongoose-autopopulate module exposes a single function that you can pass to Mongoose schema's plugin() function.

const schema = new mongoose.Schema({
  populatedField: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'ForeignModel',
    // The below option tells this plugin to always call `populate()` on
    // `populatedField`
    autopopulate: true
  }
});
schema.plugin(require('mongoose-autopopulate'));

Only apply this plugin to top-level schemas. Don't apply this plugin to child schemas.

// Don't do `nestedSchema.plugin(require('mongoose-autopopulate'))`.
// You only need to add mongoose-autopopulate to top-level schemas.
const nestedSchema = mongoose.Schema({
  child: { type: Number, ref: 'Child', autopopulate: true }
});
const topSchema = mongoose.Schema({ nested: nestedSchema });
topSchema.plugin(require('mongoose-autopopulate'));
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].