mongoose - Fields must be specified with a type function error - Keystone -


what want achieve in keystone

  1. i have labconfigs table looks below. each item of labconfigs table want store "userauthlevel" in domain table.

    so that's want create "array of boolean object " in domain table. below code same.

        ****************labconfigs***********************     var labconfigs = new keystone.list('labconfigs');      labconfigs.add({      configname: {type: types.text, required: true, initial: true, index: true},      description: {type: types.text, required: true, initial: true, index: true},      image: {type: types.text, required: true, initial: true, index: true},      type: {type: types.text, required: true, initial: true, index: true},      version: {type: types.text, required: true, initial: true, index: true},     });     ************************************************ 

    below code domain table :-

        **************************domain table******       var domain = new keystone.list('domain');      domain.add({       domainname: {type: types.text, required: true, initial: true, index: true},      labconfigs :{type: types.relationship, ref: 'labconfigs',required: false,many: true},      userauthlevel:[{ type: types.boolean}]      });     domain.defaultcolumns = 'domainname';     domain.register(); 

    but after running throw give me error :-

       throw new error('fields must specified type function');     ^ 

    to solve problem tried following code in domain table

        domain.schema.add ({            userauthlevel :                       [{                       type: types.text                      }]          }); 

    but not help.

    any suggestions how solve problem know might work in mongoose.

you're incorrectly specifying array of booleans userauthlevel property. keystone doesn't have boolean array type, has types.textarray can use store multiple possible booleans on document.

userauthlevel: { types: types.textarray } 

any array pass considered array of strings, you'd have convert stored values proper true/false value on own.


Comments