What causes the SimpleSchema is not a constructor error at collections.js

154 Views Asked by At

When using simpl-schema I am getting the following error:

SimpleSchema is not a constructor

I have already added

aldeed:autoform
aldeed:collection2@3.0.0
"simpl-schema": "^1.4.3"

My code:

import { Mongo } from 'meteor/mongo';    
import  SimpleSchema  from 'simpl-schema';     
export const Books = new Mongo.Collection("books");     
const Book = new SimpleSchema({
    title: {
        type: String,
        label: "Title",
        max: 200
    },
    author: {
        type: String,
        label: "Author"
    },
    copies: {
        type: SimpleSchema.Integer,
        label: "Number of copies",
        min: 0
    },
    lastCheckedOut: {
        type: Date,
        label: "Last date this book was checked out",
        optional: true
    },
    summary: {
        type: String,
        label: "Brief summary",
        optional: true,
        max: 1000,
        optional: true
    }
});
Books.attachSchema(Book);

What's causing it and how can I fix it?

0

There are 0 best solutions below