Hello! I tried create polymorphic relationships for my collection type “resource”
“attributes”: {
[…]
“related”: {
“collection”: “*”,
“filter”: “field”
}
}
and i have any other collection (products, categories e.t.c). I want create new resource then created product or category and linked with resource.
Product.settings.json
“resources”: {
“model”: “resource”,
“via”: “related”
}
model/product.js
module.exports = {
lifecycles: {
async afterCreate(result, attr, options) {
await strapi.query(‘resource’).create({
title: result.title,
description: result.description,
related: result
})
}
}
};
and i see error “error TypeError: refs.forEach is not a function”
Please, can you explain me how work polymorphic relationships and can i resolve this problem? Thanks!
System Information
- strapi - 3.3.4:
- OS - windows 10:
- DB - SQLite:
- Node - v14.15.1:
- NPM - 6.14.8:
- YARN - 1.22.10: