querying a collection without passing schema in mongoose

后端 未结 3 1221
情深已故
情深已故 2020-12-13 04:54

Do i understand correctly, that if i want to query a collection, i have to do the following:

    var mongoose = require(\"mongoose\");

mongoose.connect();

         


        
3条回答
  •  执笔经年
    2020-12-13 05:00

    try this..

    const mongoose = require('mongoose');
    const Schema = mongoose.Schema;
    
    const ProductSchema = new Schema({}, { strict: false });
    const Product = mongoose.model('Product', ProductSchema, 'products');
    
    module.exports = { Product };
    

提交回复
热议问题