This repository was archived by the owner on Sep 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathapp-pouchdb-query.d.ts
More file actions
133 lines (121 loc) · 4.08 KB
/
app-pouchdb-query.d.ts
File metadata and controls
133 lines (121 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* DO NOT EDIT
*
* This file was automatically generated by
* https://github.com/Polymer/gen-typescript-declarations
*
* To modify these typings, edit the source file(s):
* app-pouchdb-query.html
*/
/// <reference path="../polymer/types/polymer.d.ts" />
/// <reference path="app-pouchdb-database-behavior.d.ts" />
/// <reference path="pouchdb.d.ts" />
/// <reference path="pouchdb.find.d.ts" />
/**
* `app-pouchdb-query` allows for declarative, read-only querying into a PouchDB
* database. The semantics for querying match those of the
* [pouchdb-find plugin](https://github.com/nolanlawson/pouchdb-find).
*
* In order to create an `app-pouchdb-query` against any field other than `_id`, at
* least one index needs to have been created in your PouchDB database. You can use
* `app-pouchdb-index` to do this declaratively. For example:
*
* ```html
* <app-pouchdb-index
* db-name="cats"
* fields='["name"]'>
* </app-pouchdb-index>
* <app-pouchdb-query
* db-name="cats"
* selector="name $exists true"
* fields='["_id","name"]'
* sort='["name"]'
* data="{{cats}}">
* </app-pouchdb-query>
* ```
*
* In the above example, an index is created on the "name" field of the "cats"
* database. This allows the query to select by the "name" field, and sort by the
* "name" field.
*
* By default, PouchDB creates an index on the "_id" field, so if you don't
* particularly care about sorting or selecting on other fields, you don't need to
* create any extra indexes.
*
* ## Describing selectors
*
* This element requires a specialized selector syntax that maps to the semantics
* of the pouchdb-find plugin. For example, if you wish to create the following
* selector:
*
* ```javascript
* {
* series: 'Mario',
* debut: { $gt: 1990 }
* }
* ```
*
* You should format the `selector` property this way:
*
* ```javascript
* "series $eq 'Mario', debut $gt 1990"
* ```
*
* This makes selectors more convenient to write declaratively, while still
* maintaining the ability to express selectors with full fidelity. For more
* documentation on pouchdb-find selectors, please check out the docs
* [here](https://github.com/nolanlawson/pouchdb-find#dbfindrequest--callback).
*/
interface AppPouchdbQueryElement extends Polymer.Element, Polymer.AppPouchDBDatabaseBehavior {
/**
* The selector to use when querying for documents. Fields referenced
* in the selector must have indexes created for them.
*/
selector: string|null|undefined;
/**
* The fields to include in the returned documents.
*/
fields: any[]|null|undefined;
/**
* A list of field names to sort by. Fields in this list must have
* indexes created for them.
*/
sort: any[]|null|undefined;
/**
* The maximum number of documents that can be returned. The default (0)
* specifies no limit.
*/
limit: number|null|undefined;
/**
* The number of documents to skip before returning results that match
* the query. In other words, the offset from the beginning of the
* of the result set to start at.
*/
skip: number|null|undefined;
/**
* An object representing the parsed form of the selector, mapping to
* a valid selector value as described in
* [the pouchdb-find docs](https://github.com/nolanlawson/pouchdb-find).
*/
readonly parsedSelector: object|null|undefined;
/**
* A configuration object suitable to be passed to the `find` method of
* the PouchDB database. For more information, refer to the docs
* [here](https://github.com/nolanlawson/pouchdb-find/blob/master/README.md#dbfindrequest--callback)
*/
readonly query: object|null|undefined;
/**
* The results of the query, if any.
*/
readonly data: any[]|null|undefined;
/**
* PouchDB only notifies of additive changes to the result set of a query.
* In order to keep the query results up to date with other types of
* changes, this method can be called to perform the query again without
* changing any of this element's other properties.
*/
refresh(): void;
}
interface HTMLElementTagNameMap {
"app-pouchdb-query": AppPouchdbQueryElement;
}