Фильтр Strapi по связанным пользователям в Strapi во взаимоотношениях «многие ко многим»Javascript

Форум по Javascript
Ответить
Anonymous
 Фильтр Strapi по связанным пользователям в Strapi во взаимоотношениях «многие ко многим»

Сообщение Anonymous »

Код: Выделить всё

const projects = await strapi.entityService.findMany('api::project.project', {
filters: { users: { id: { $eq: userId } } },
populate: ['tenant', 'users'],
});
приведенный выше код работает нормально, но когда я пытаюсь запустить это rest api
/api/projects?populate[0]=user&populate[1]=tenant&filters[users][id][$eq]=35
схема разрешений пользователя

Код: Выделить всё

{
"kind": "collectionType",
"collectionName": "up_users",
"info": {
"name": "user",
"description": "",
"singularName": "user",
"pluralName": "users",
"displayName": "User"
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"username": {
"type": "string",
"minLength": 3,
"unique": true,
"configurable": false,
"required": true
},
"email": {
"type": "email",
"minLength": 6,
"configurable": false,
"required": true
},
"provider": {
"type": "string",
"configurable": false
},
"password": {
"type": "password",
"minLength": 6,
"configurable": false,
"private": true,
"searchable": false
},
"resetPasswordToken": {
"type": "string",
"configurable": false,
"private": true,
"searchable": false
},
"confirmationToken": {
"type": "string",
"configurable": false,
"private": true,
"searchable": false
},
"confirmed": {
"type": "boolean",
"default": false,
"configurable": false
},
"blocked": {
"type": "boolean",
"default": false,
"configurable": false
},
"role": {
"type": "relation",
"relation": "manyToOne",
"target": "plugin::users-permissions.role",
"inversedBy": "users",
"configurable": false
},
"mobileNo": {
"type": "biginteger",
"unique": true
},
"tenant": {
"type": "relation",
"relation": "manyToOne",
"target": "api::tenant.tenant",
"inversedBy": "users"
},
"projects": {
"type": "relation",
"relation": "manyToMany",
"target": "api::project.project",
"mappedBy": "users"
}
}
}

схема модели проекта

Код: Выделить всё

{
"kind": "collectionType",
"collectionName": "projects",
"info": {
"singularName": "project",
"pluralName": "projects",
"displayName": "Project"
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string",
"unique": true
},
"tenant": {
"type": "relation",
"relation": "manyToOne",
"target": "api::tenant.tenant",
"inversedBy": "projects"
},
"description": {
"type": "text"
},
"users": {
"type": "relation",
"relation": "manyToMany",
"target": "plugin::users-permissions.user",
"inversedBy":  "projects"
}
}
}

я получаю ошибку проверки
подробности
:
{key: "users", путь: "users", источник: "query", параметр: "filters"
message
:
"Неверный ключ пользователей"
name
:
"ValidationError"
status
:
400

Подробнее здесь: https://stackoverflow.com/questions/798 ... lationship
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Javascript»