oramasearch / orama-plugin-strapi

4 stars 1 forks source link

Fix: No relation attribute selected #7

Closed giogaspa closed 1 month ago

giogaspa commented 1 month ago

Hey, I found a small bug on collection editing. If you select a relation (one or more) but then don't select any attributes of the relation, the code throws the following error:

/Users/giogaspa/Projects/Orama/orama-strapi-4-playground/node_modules/@oramacloud/plugin-strapi/server/services/content-types.js:54
      select: Object.keys(schema[relation]).map((key) => key)
                     ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at /Users/giogaspa/Projects/Orama/orama-strapi-4-playground/node_modules/@oramacloud/plugin-strapi/server/services/content-types.js:54:22
    at Array.reduce (<anonymous>)
    at getSelectedRelations (/Users/giogaspa/Projects/Orama/orama-strapi-4-playground/node_modules/@oramacloud/plugin-strapi/server/services/content-types.js:52:6)
    at Object.getEntries (/Users/giogaspa/Projects/Orama/orama-strapi-4-playground/node_modules/@oramacloud/plugin-strapi/server/services/content-types.js:83:33)
    at OramaManager.bulkInsert (/Users/giogaspa/Projects/Orama/orama-strapi-4-playground/node_modules/@oramacloud/plugin-strapi/server/services/orama-manager.js:84:52)
    at OramaManager.afterCollectionCreationOrUpdate (/Users/giogaspa/Projects/Orama/orama-strapi-4-playground/node_modules/@oramacloud/plugin-strapi/server/services/orama-manager.js:166:44)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.14.0

This is the modal where you can set the collection:

image