mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-19 13:56:04 +00:00
added index on media entity_id, report query with unindexed fields
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
UnableToConnectException
|
||||
} from "../errors";
|
||||
import { MutatorEvents, RepositoryEvents } from "../events";
|
||||
import type { Field } from "../fields/Field";
|
||||
import type { EntityIndex } from "../fields/indices/EntityIndex";
|
||||
import type { EntityRelation } from "../relations";
|
||||
import { RelationAccessor } from "../relations/RelationAccessor";
|
||||
@@ -142,6 +143,16 @@ export class EntityManager<TBD extends object = DefaultDB> {
|
||||
return this.indices.some((e) => e.name === name);
|
||||
}
|
||||
|
||||
// @todo: add to Connection whether first index is used or not
|
||||
getIndexedFields(_entity: Entity | string): Field[] {
|
||||
const entity = this.entity(_entity);
|
||||
const indices = this.getIndicesOf(entity);
|
||||
const rel_fields = entity.fields.filter((f) => f.type === "relation");
|
||||
// assuming only first
|
||||
const idx_fields = indices.map((index) => index.fields[0]);
|
||||
return [entity.getPrimaryField(), ...rel_fields, ...idx_fields].filter(Boolean) as Field[];
|
||||
}
|
||||
|
||||
addRelation(relation: EntityRelation) {
|
||||
// check if entities are registered
|
||||
if (!this.entity(relation.source.entity.name) || !this.entity(relation.target.entity.name)) {
|
||||
|
||||
Reference in New Issue
Block a user