Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

How to autopopulate from a GridFS schema? #78

@Josecongas

Description

@Josecongas

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,
    },
  ],
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions