mongoose-plugin-dataloader

    1.0.3 • Public • Published

    mongoose-plugin-dataloader

    Adds load and loadMany to models.

    Getting Started

    npm install mongoose-plugin-dataloader --save

    const { Schema, model } = require('mongoose')
    const dataloaderPlugin = require('mongoose-plugin-dataloader')
     
    const schema = {
      email: {
        type: String,
        required: true,
        unique: true
      }
    }
     
    const userSchema = new Schema(schema, { timestamps: true })
     
    userSchema.plugin(dataloaderPlugin)
     
    module.exports = model('User', userSchema)
    const User = require('./user-model');
    // info from GraphQL resolver
    User.loadMany(ids, info)
    User.load(id, info)

    Install

    npm i mongoose-plugin-dataloader

    DownloadsWeekly Downloads

    5

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    1.86 kB

    Total Files

    4

    Last publish

    Collaborators

    • rnsantos