Skip to content

Declarative: Decorators

@NodeFragment({ labels: ['Proposition'] })
export class PropositionNode {
@NodeId() @RangeIndex() @Unique() id: string;
@RangeIndex() contextId: string;
@VectorIndex({ similarity: 'COSINE' }) embedding?: number[];
@FullTextIndex() body: string; // also what loadMatching searches
}
// composite declarations go on the class
@NodeFragment({ labels: ['Message'] })
@RangeIndex({ properties: ['sessionId', 'createdAt'] })
@Unique({ properties: ['sessionId', 'sequence'] })
@FullTextIndex({ properties: ['subject', 'body'] })
export class MessageNode { /* … */ }

A field may carry several of these, as id does: each is made. A subclass that decorates an inherited field again replaces all of its superclass’s declarations on it.

@RangeIndex({ ignoreCase: true }) and @Unique({ ignoreCase: true }) on a @CaseInsensitive field are made over the lowercased copy a save keeps of it, so they serve eqIgnoreCase and refuse two values that differ only in case. Ensuring one fills the copies in first. See Lookups That Ignore Case. The object manager keeps the copy in step, but Cypher you send yourself doesn’t: set the copy in the same statement, or recreate the index, or drop and ensure the constraint, afterwards to fill it in again (how).