How to use the webiny-entity.EntityCollection function in webiny-entity

To help you get started, we’ve selected a few webiny-entity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / webiny-api-security / src / entities / helpers / onSetFactory.js View on Github external
// If not DB ids - load entities by slugs
                if (!EntityClass.isId(value)) {
                    if (typeof value === "string") {
                        query = { slug: value };
                    } else if (value.id) {
                        query = { id: value.id };
                    } else if (value.slug) {
                        query = { slug: value.slug };
                    }
                }

                // TODO: ne bi htio loadati entitet tu jer to je samo populate
                entities[i] = await EntityClass.findOne({ query });
            }

            return new EntityCollection(entities.filter(Boolean));
        }

        return entities;
    };
};