System Information
- Strapi Version:
- Operating System:
- Database:
- Node Version:
- NPM Version:
- Yarn Version:
I am trying to populate the database with a JSON file and following this tutorial: Import data from file | Strapi
It explains how you can add relational data without an example. I have categories in a separate collection, but struggling to source it as find is undefined.
Has anyone got an example I and others could use?
Or, tell me where I am going wrong?
const { offers } = require('../../data/offers.json');
module.exports = async() => {
offers.forEach(offer => {
const findCategoryItem = async (identifier) => {
const result = await strapi
.query["offer-category"]
.find({ id: identifier });
return result;
};
const offerCategory = findCategoryItem('604fa6eaa818b7e08079ee1a')
console.log(findCategoryItem('604fa6eaa818b7e08079ee1a'))
strapi.services.offer.create({
offer_category: {Category: offerCategory.name}
})
})
}
Thanks