@react-native-ohos/realm
Version:
Realm by MongoDB is an offline-first mobile database: an alternative to SQLite and key-value stores
79 lines (78 loc) • 3.12 kB
TypeScript
import { binding } from "./binding";
import { OrderedCollection } from "./OrderedCollection";
import type { Realm } from "./Realm";
import { type SubscriptionOptions } from "./app-services/MutableSubscriptionSet";
import type { TypeHelpers } from "./TypeHelpers";
import type { Unmanaged } from "./Unmanaged";
import type { ResultsAccessor } from "./collection-accessors/Results";
/**
* Instances of this class are typically **live** collections returned by
* objects() that will update as new objects are either
* added to or deleted from the Realm that match the underlying query. Results returned by
* snapshot()}, however, will **not** live update
* (and listener callbacks added through addListener()
* will thus never be called).
* @see https://www.mongodb.com/docs/realm/sdk/react-native/model-data/data-types/collections/
*/
export declare class Results<T = unknown> extends OrderedCollection<T, [
number,
T
],
/** @internal */
ResultsAccessor<T>> {
/**
* The representation in the binding.
* @internal
*/
readonly internal: binding.Results;
/** @internal */
subscriptionName?: string;
/**
* Create a `Results` wrapping a set of query `Results` from the binding.
* @internal
*/
constructor(realm: Realm, internal: binding.Results, accessor: ResultsAccessor<T>, typeHelpers: TypeHelpers<T>);
/** @internal */
get(index: number): T;
/** @internal */
set(): never;
get length(): number;
set length(value: number);
description(): string;
/**
* Bulk update objects in the collection.
* @param propertyName - The name of the property.
* @param value - The updated property value.
* @throws An {@link Error} if no property with the name exists.
* @since 2.0.0
*/
update(propertyName: keyof Unmanaged<T>, value: Unmanaged<T>[typeof propertyName]): void;
/**
* Add this query result to the set of active subscriptions. The query will be joined
* via an `OR` operator with any existing queries for the same type.
* @param options - Options to use when adding this subscription (e.g. a name or wait behavior).
* @returns A promise that resolves to this {@link Results} instance.
* @experimental This API is experimental and may change or be removed.
*/
subscribe(options?: SubscriptionOptions): Promise<this>;
/**
* Unsubscribe from this query result. It returns immediately without waiting
* for synchronization.
*
* If the subscription is unnamed, the subscription matching the query will
* be removed.
* @experimental This API is experimental and may change or be removed.
*/
unsubscribe(): void;
/**
* Checks if this results collection has not been deleted and is part of a valid Realm.
* @returns `true` if the collection can be safely accessed.
*/
isValid(): boolean;
/**
* Checks if this collection result is empty.
* @returns `true` if the collection result is empty, `false` if not.
*/
isEmpty(): boolean;
}
export type AnyResults = Results<any>;