Interface QueryOpts

Query behavior options.

interface QueryOpts {
    cwise: boolean;
    equiv: Predicate2<any>;
    intersect: boolean;
    partial: boolean;
}

Properties

cwise: boolean

If true (default), any array or Set values in the target object's O(bject) position will be matched componentwise rather than matched as array value themselves.

Remarks

Array or Set terms in S(ubject) or P(redicate) position are of course ALWAYS matched in a componentwise manner.

Example

import { defQuery } from "@thi.ng/oquery";

const DB = { a: { knows: ["b","c"] }, b: { knows: ["a","c"] }};
defQuery({ cwise: true })(DB, null, "knows", "b")
// { a: { knows: ["b","c"] } }

defQuery({ cwise: false })(DB, null, "knows", (x) => x.includes("b"))
// { a: { knows: ["b","c"] } }

Default Value

true
equiv: Predicate2<any>

Equality predicate applied for matching literals in O(bject) position.

Default Value

thi.ng/equiv#equiv
intersect: boolean

Only used if cwise is enabled. If true, ALL of the query elements must match (aka intersection query). If false (default), an array or Set query term in O(bject) position will succeed if at least ONE of its elements is matched (aka union query). .

Default Value

false
partial: boolean

If false (default), an entire object is included in the solution as soon as any of its P(redicate)-O(bject) terms matches. If true, only the successfully matched property values will be included for each result.

Example

import { defQuery } from "@thi.ng/oquery";

const DB = { a: { id: 1, name: "alice" }, b: { name: "bob" } };

defQuery({ partial: false })(DB, null, "id", 1)
// { a: { id: 1, name: "alice" } }

defQuery({ partial: true })(DB, null, "id", 1)
// { a: { id: 1 } }

Default Value

false

Generated using TypeDoc