GithubHelp home page GithubHelp logo

Comments (4)

mgan59 avatar mgan59 commented on June 21, 2024

@roger-kaybus k will look into it. I remember thinking at one point that the interface seemed redundant, but there was a reason I made the decision and I think it has to do with the way mongoose works. I'll look into it and let you know.

from mongoose-fixture.

mgan59 avatar mgan59 commented on June 21, 2024

Reviewed some of the code fairly quickly. I think my intention was as follows.

A little background on Mongoosejs, by default it will take whatever 'ModelKey' you pass into Mongoose.model('ModelKey', Schema) and if you do not specify a collection name in the schema.options.collection it will attempt to generate one for you. For instance if you did Mongoose.model('Kitten', Schema) it would create a collection in mongodb called kittens.

There are problems with Mongoosejs auto-generating collection names, specifically I had an instance of the model 'Facility' which was generating facilitys which is inaccurate I wanted facilities so in my schema I set the collection option to facilities. The problem then when I ran mongoose-fixture with just a collection key of 'facilities' the Mongoose.model(...) method was incapable of finding the correct model/collection mapping. Even though the delete would work since the collection name did map correctly.

So... with that said I reviewed my project that has multiple mis-matching itemName / collection names and they work fine... I think your problem might be in setting two different values you need to map your fixture.collection to the custom collection name you define on your scheme

module.exports = function(mongoose){

    var facilitySchema = mongoose.Schema({
            internalName:{type:String},
            name:{type:String},
        },
        // extra options, this overrides the default collection name
        // that would be set by model as facilitys
        {
            collection:'facilities'   
        }
    );

    return facilitySchema;
};

Let me know if this solves your problem. Maybe I'll see what my options are for warning a client that by mis-matching itemName and Collection requires the collection to be defined on the scheme. Pretty sure I can bubble the message up.

from mongoose-fixture.

mgan59 avatar mgan59 commented on June 21, 2024

@roger-kaybus when you get a chance let me know the status and if you're all set please close the issue.

from mongoose-fixture.

 avatar commented on June 21, 2024

its working for me fine right now. I'll close this.

from mongoose-fixture.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.