简体   繁体   中英

Meteor server is crashing on SimpleSchema autoValue option

I'm new working with MeteorJS dev an app, this is a problem when I'm making the collection of some item in an quick inventory app.

Here is the error:

/home/operador/.meteor/packages/meteor-tool/.1.1.10.1kpywhr++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
                    throw(ex);
                          ^
Error: Invalid definition for active field.
at packages/aldeed_simple-schema/packages/aldeed_simple-schema.js:1328:1
at Function._.each._.forEach (packages/underscore/underscore.js:113:1)
at [object Object].SimpleSchema (packages/aldeed_simple-schema/packages/aldeed_simple-schema.js:1325:1)
at collections/assets.js:16:16
at /home/operador/fijos/.meteor/local/build/programs/server/app/collections/assets.js:64:4
at /home/operador/fijos/.meteor/local/build/programs/server/boot.js:242:10
at Array.forEach (native)
at Function._.each._.forEach (/home/operador/.meteor/packages/meteor-tool/.1.1.10.1kpywhr++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
at /home/operador/fijos/.meteor/local/build/programs/server/boot.js:137:5
Exited with code: 8
Your application is crashing. Waiting for file change.

And this is the assets.js :

Assets = new Mongo.Collection('assets')

Assets.allow({
    insert: function(userId, userLvl, doc) {
        return !!userId;
    }
});

Brands = new SimpleSchema({
    name: {
        type: String,
        label: "Brand"
    }
});

Assetsschema = new SimpleSchema({
    item: {
        type: String,
        label: "item"
    },
    year: {
        type: Date,
        label: "year"
    },
    model: {
        type: String,
        label: "model"
    },
    serialNumber: {
        type: String,
        label: "serialNumber"
    },
    brand: {
        type: [Brands]
    },
    adquarance: {
        type: Date,
        label: "adquaranceDate"
    },
    codebar: {
        type: String,
        label: "codebar"
    },
    qrcode: {
        type: String,
        label: "QRcode"
    },
    active: {
        type: Boolean,
        label: "active",
        autoValue: true
    }
});

IDK how to fix the problem, I've tried to change the name of the schema but that gave me the same results.

This is my package list:

kadira:flow-router
kadira:blaze-layout
erasaur:meteor-lodash
fortawesome:fontawesome
spiderable
fastclick
raix:handlebar-helpers
aldeed:collection2
aldeed:autoform
accounts-ui
accounts-password
matb33:bootstrap-glyphicons
zimme:active-route
gwendall:auth-client-callbacks
meteortoys:allthings
datariot:ganalytics
bootswatch:paper
numtel:mysql
hitchcott:qr-scanner

The option autoValue allows you to specify a function. As a consequence, your Schema should be structured as follows:

Assetsschema = new SimpleSchema({
    item: {
        type: String,
        label: "item"
    },
    year: {
        type: Date,
        label: "year"
    },
    model: {
        type: String,
        label: "model"
    },
    serialNumber: {
        type: String,
        label: "serialNumber"
    },
    brand: {
        type: [Brands]
    },
    adquarance: {
        type: Date,
        label: "adquaranceDate"
    },
    codebar: {
        type: String,
        label: "codebar"
    },
    qrcode: {
        type: String,
        label: "QRcode"
    },
    active: {
        type: Boolean,
        label: "active",
        autoValue: function () {
            return true;
        }
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM