Code Monkey home page Code Monkey logo

Comments (5)

duartealexf avatar duartealexf commented on July 3, 2024 1

Thanks @JKHeadley,
I used the first solution and it worked.

I also found another way to fix it:

cols: {
    type: Array,
    default: []
}

from rest-hapi.

JKHeadley avatar JKHeadley commented on July 3, 2024

That error would occur if you are not assigning a type to one of your 'layout' model properties. For example:

module.exports = function (mongoose) {
  var modelName = "role";
  var Types = mongoose.Schema.Types;
  var Schema = new mongoose.Schema({
    name: {
      type: Types.String,                                                  //<-----type
      enum: ["Account", "Admin", "SuperAdmin"],
      required: true
    },
    enabled: {
      type: Types.Boolean                                               //<-----type
    }
  }, { collection: modelName });
    
  Schema.statics = {
    collectionName:modelName,
    routeOptions: {
    }
  };

  return Schema;
};

from rest-hapi.

duartealexf avatar duartealexf commented on July 3, 2024

Thanks for the reply @JKHeadley, but actually I am setting the type. Might this error be because of my 'cols' empty array property? This is my model:

module.exports = function (mongoose) {
    var modelName = "layout";
    var Types = mongoose.Schema.Types;


    var schema = new mongoose.Schema({
        name: {
            type: Types.String,
            required: true
        },
        thumb: {
            type: Types.String
        },
        cols: []
    }, { collection: modelName });

...

I'm also setting some schema.statics after that, but I'm not sure it is related to the error.

Thanks again.

from rest-hapi.

duartealexf avatar duartealexf commented on July 3, 2024

Hi again, I'm debugging it and it seems to be from the empty array. Here's the print:

image

Is it? How would be the correct way of doing this? Thanks.

from rest-hapi.

JKHeadley avatar JKHeadley commented on July 3, 2024

yes, it is due to the empty cols array. If you assign a type to the array, it should fix that, for example:

cols: [Types.String]

or even

cols: [{}]

should work.

from rest-hapi.

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.