FeathersJS 无法使用 ObjectionJS 和 SQLite 创建用户
FeathersJS cannot create user with ObjectionJS and SQLite
我正在试验 FeathersJS。为此,我生成了一个新的羽毛应用程序
$ feathers g app
具有以下配置:
? Do you want to use JavaScript or TypeScript? JavaScript
? Project name test
? Description
? What folder should the source files live in? src
? Which package manager are you using (has to be installed globally)? npm
? What type of API are you making? REST, Realtime via Socket.io
? Which testing framework do you prefer? Mocha + assert
? This app uses authentication Yes
? Which coding style do you want to use? ESLint
? What authentication strategies do you want to use? (See API docs for all 180+ supported oAuth providers) Username + Password (Local)
? What is the name of the user (entity) service? users
? What kind of service is it? Objection
? Which database are you connecting to? SQLite
? What is the database connection string? sqlite://test.sqlite
当我 运行 测试套件 $ npm run tests
时,它抛出错误 ERR GeneralError: strict mode: unknown keyword: "0"
到目前为止,我了解到此错误是在 Knex 使用的 AJV 中的某处引发的,并且它在某种程度上与架构验证有关。我也尝试发布到 http://localhost:3030/users
以创建用户,但我得到了同样的错误。
我 运行 使用配置为使用 Knex + SQLite 和 Sequalize + SQLite 的应用程序进行相同的实验。这些设置让我可以创建新用户。
有谁知道这个错误可能来自哪里以及如何解决?
找到问题了。羽毛生成器在 ObjectionJS 模型中创建以下 jsonSchema:
static get jsonSchema() {
return {
type: 'object',
required: ['password'],
properties: {
email: { type: ['string', 'null'] },
password: 'string',
}
};
}
密码语法错误属性。它需要 password: { type: 'string' }
才能工作。
我正在试验 FeathersJS。为此,我生成了一个新的羽毛应用程序
$ feathers g app
具有以下配置:
? Do you want to use JavaScript or TypeScript? JavaScript
? Project name test
? Description
? What folder should the source files live in? src
? Which package manager are you using (has to be installed globally)? npm
? What type of API are you making? REST, Realtime via Socket.io
? Which testing framework do you prefer? Mocha + assert
? This app uses authentication Yes
? Which coding style do you want to use? ESLint
? What authentication strategies do you want to use? (See API docs for all 180+ supported oAuth providers) Username + Password (Local)
? What is the name of the user (entity) service? users
? What kind of service is it? Objection
? Which database are you connecting to? SQLite
? What is the database connection string? sqlite://test.sqlite
当我 运行 测试套件 $ npm run tests
时,它抛出错误 ERR GeneralError: strict mode: unknown keyword: "0"
到目前为止,我了解到此错误是在 Knex 使用的 AJV 中的某处引发的,并且它在某种程度上与架构验证有关。我也尝试发布到 http://localhost:3030/users
以创建用户,但我得到了同样的错误。
我 运行 使用配置为使用 Knex + SQLite 和 Sequalize + SQLite 的应用程序进行相同的实验。这些设置让我可以创建新用户。
有谁知道这个错误可能来自哪里以及如何解决?
找到问题了。羽毛生成器在 ObjectionJS 模型中创建以下 jsonSchema:
static get jsonSchema() {
return {
type: 'object',
required: ['password'],
properties: {
email: { type: ['string', 'null'] },
password: 'string',
}
};
}
密码语法错误属性。它需要 password: { type: 'string' }
才能工作。