Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to autopopulate from a GridFS schema? #78

Open
Josecongas opened this issue Dec 9, 2020 · 1 comment
Open

How to autopopulate from a GridFS schema? #78

Josecongas opened this issue Dec 9, 2020 · 1 comment

Comments

@Josecongas
Copy link

I need to autopopulate from a GridFS schema but it is not working:

import * as mongoose from 'mongoose';
import { Schema } from 'mongoose';
import * as autopopulate from 'mongoose-autopopulate';

const IngredientsSchema = new mongoose.Schema(
  {
    length: { type: Number },
    chunkSize: { type: Number },
    uploadDate: { type: Date },
    filename: { type: String, trim: true, searchable: true },
    md5: { type: String, trim: true, searchable: true },
  },
  { collection: 'ingredients.files', id: false },
);

export const PizzaSchema = new mongoose.Schema({
  name: String,
  shapes: [
    {
      type: mongoose.Schema.Types.ObjectId,
      ref: IngredientsSchema,
      autopopulate: true,
    },
  ],
});
@vkarpov15
Copy link
Member

  1. "not working" is not a bug report. Please clarify what your expected behavior is and what the observed behavior is. For example, was there some sort of error?

  2. Your ref is wrong, ref should be the model name, not a schema instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants