P@
А вон, получается что еще висит.
Size: a a a
P@
A
A
A
Д
DV
Д
DV
DV
AS
AS
const User = sequelize.define('user', {
{
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
},
email: {
type: STRING,
unique: true,
allowNull: false,
validate: {
notEmpty: true,
isEmail: true,
},
},
},
})
nst Role = db.define(Мне нужно получить информацию о пользователе, не делая второй запрос на получение пользователя по ID в поле crea
'role',
{
name: {
type: STRING,
unique: true,
allowNull: false,
validate: {
notEmpty: true,
},
},
},
})
Role.associate = ({ User }) => {
Role.belongsTo(User, {
foreignKey: {
name: 'createdBy',
field: 'createdBy',
},
})
}
tedBy
Сх
ема GraphQLnd type Query {создаю пользователя и роль, добавляя только что созданного пользователя в качестве создателя роли:
roles(offset: Int, limit: Int): [Role!]
}
type User {
id: Int!
email: EmailAddress!
}
type Role {
id: Int!
name: String!
createdBy: User!
}
Я
stScenario = async ({ DataTable, Role, User }) => {я пытаюсь получить список ролей, получаю ошибку: "message":
const kanyeWest = await User.create({
email: 'kanye.west@gmail.com',
})
await Role.create({
name: 'Admin',
createdBy: kanyeWest
}
Когда
"Cannot return null for non-nullable field User.id."
query Ro
les {я изменю поле createdBy в
roles(offset: 0, limit: 5) {
id
name
createdBy {
id
}
}
}
Но, если
схеме на
Int, я получу а
йдишник пользователяД
AN
const User = sequelize.define('user', {
{
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
},
email: {
type: STRING,
unique: true,
allowNull: false,
validate: {
notEmpty: true,
isEmail: true,
},
},
},
})
nst Role = db.define(Мне нужно получить информацию о пользователе, не делая второй запрос на получение пользователя по ID в поле crea
'role',
{
name: {
type: STRING,
unique: true,
allowNull: false,
validate: {
notEmpty: true,
},
},
},
})
Role.associate = ({ User }) => {
Role.belongsTo(User, {
foreignKey: {
name: 'createdBy',
field: 'createdBy',
},
})
}
tedBy
Сх
ема GraphQLnd type Query {создаю пользователя и роль, добавляя только что созданного пользователя в качестве создателя роли:
roles(offset: Int, limit: Int): [Role!]
}
type User {
id: Int!
email: EmailAddress!
}
type Role {
id: Int!
name: String!
createdBy: User!
}
Я
stScenario = async ({ DataTable, Role, User }) => {я пытаюсь получить список ролей, получаю ошибку: "message":
const kanyeWest = await User.create({
email: 'kanye.west@gmail.com',
})
await Role.create({
name: 'Admin',
createdBy: kanyeWest
}
Когда
"Cannot return null for non-nullable field User.id."
query Ro
les {я изменю поле createdBy в
roles(offset: 0, limit: 5) {
id
name
createdBy {
id
}
}
}
Но, если
схеме на
Int, я получу а
йдишник пользователяAS
async (parent, { offset, limit }, { models: { Role, User } }) => {
const roleList = await Role.findAll({
include: [User],
order: [['id', 'ASC']],
offset,
limit,
})
return roleList
},
AN
AS
"message": "Association with alias \"createdBy\" does not exist on role"
AS
foreignKey
что-лиAN
AS
AN