Objection.js: TypeScript Error: "Object literal may only specify known properties"

Created on 25 Dec 2020  路  1Comment  路  Source: Vincit/objection.js

static get tableName () {
    return 'users'
}

static get jsonSchema () {
    return {
        type: 'object',
        required: ['id', 'email', 'username', 'password'],
        properties: {
            id: { type: 'integer' },
            email: { type: 'string', format: 'email' },
            username: { type: 'string' },
            password: { type: 'string' },
            about: { type: 'string' },
            createdAt: { type: 'string', format: 'date' }
        }
    }
}

I get the error with this query
User.query().insert({
        email: req.query.email,
        username: req.query.username,
        password: req.query.password
    })
})

Most helpful comment

Try to add this to model.

email!: string; username!: string; password!: string;

>All comments

Try to add this to model.

email!: string; username!: string; password!: string;

Was this page helpful?
0 / 5 - 0 ratings