[iobroker] add getObjectList[Async] to the adapter interface (#41272)

This commit is contained in:
AlCalzone
2019-12-31 15:19:53 -08:00
committed by Ryan Cavanaugh
parent 98feb5a0f0
commit 1d52577a72
2 changed files with 34 additions and 1 deletions
+25 -1
View File
@@ -332,7 +332,7 @@ declare global {
/** Parameters for @link{Objects.getObjectList} */
interface GetObjectListParams extends GetObjectViewParams {
/** Whether docs should be included in the return list */ // TODO: What are docs?
include_docs: boolean;
include_docs?: boolean;
}
type LogLevel = 'silly' | 'debug' | 'info' | 'warn' | 'error';
@@ -839,6 +839,30 @@ declare global {
options?: unknown,
): Promise<NonNullCallbackReturnTypeOf<GetObjectViewCallback>>;
/**
* Returns a list of objects with id between params.startkey and params.endkey
* @param params Parameters determining the objects included in the return list. Null to include all objects
* @param options If the returned list should be sorted. And some internal options.
* @param callback Is called when the operation has finished (successfully or not)
*/
// TODO: options should be optional: https://github.com/ioBroker/ioBroker.js-controller/issues/574
// getObjectList(params: GetObjectListParams | null, callback: GetObjectListCallback): void;
getObjectList(
params: GetObjectListParams | null,
options: { sorted?: boolean } | Record<string, any>,
callback: GetObjectListCallback,
): void;
/**
* Returns a list of objects with id between params.startkey and params.endkey
* @param params Parameters determining the objects included in the return list. Null to include all objects
* @param options If the returned list should be sorted. And some internal options.
* @param callback Is called when the operation has finished (successfully or not)
*/
getObjectListAsync(
params: GetObjectListParams | null,
options: { sorted?: boolean } | Record<string, any>,
): Promise<NonNullCallbackReturnTypeOf<GetObjectListCallback>>;
// ==============================
// states
+9
View File
@@ -198,6 +198,15 @@ adapter.getObjectViewAsync("system", "admin", {startkey: "foo", endkey: "bar"}).
docs && docs.rows[0] && docs.rows[0].id.toLowerCase();
});
// TODO: https://github.com/ioBroker/ioBroker.js-controller/issues/574
// {} should be left out or undefined
adapter.getObjectList({startkey: "foo", endkey: "bar"}, {}, (err, result) => {
result && result.rows[0] && result.rows[0].id.toLowerCase();
});
adapter.getObjectListAsync({startkey: "foo", endkey: "bar"}, {}).then(result => {
result && result.rows[0] && result.rows[0].id.toLowerCase();
});
adapter.subscribeObjects("*");
adapter.subscribeStates("*");
adapter.subscribeForeignObjects("*");