Skip to content

Commit ee50585

Browse files
authored
improve TypeScript definitions for Mango selectors - fixes issue #202 (#205)
1 parent 0e2b69e commit ee50585

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

lib/nano.d.ts

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,36 +1274,16 @@ declare namespace nano {
12741274
update_seq: any;
12751275
}
12761276

1277-
type MangoValue = number | string | Date | boolean | null;
1278-
12791277
// http://docs.couchdb.org/en/latest/api/database/find.html#selector-syntax
1280-
1281-
enum ConditionOperands {
1282-
$lt = '$lt',
1283-
$lte = '$lte',
1284-
$eq = '$eq',
1285-
$ne = '$ne',
1286-
$gte = '$gte',
1287-
$gt = '$gt'
1288-
}
1289-
1290-
enum ArrayFieldOperands {
1291-
$in = '$in',
1292-
$nin = '$nin'
1278+
type MangoValue = number | string | Date | boolean | object | null;
1279+
type MangoOperator = '$lt' | '$lte' | '$eq' | '$ne' | '$gte' | '$gt' |
1280+
'$exists' | '$type' |
1281+
'$in' | '$nin' | '$size' | '$mod' | '$regex' |
1282+
'$or' | '$and' | '$nor' | '$not' | '$all' | '$allMatch' | '$elemMatch';
1283+
type MangoSelector = {
1284+
[K in MangoOperator]: MangoSelector | MangoValue | MangoValue[];
12931285
}
12941286

1295-
enum CombinationOperands {
1296-
$or = '$or',
1297-
$and = '$and',
1298-
$nor = '$nor',
1299-
$all = '$all'
1300-
}
1301-
1302-
type MangoSelector = { [key: string]: MangoSelector | MangoValue | MangoValue[]; }
1303-
| Partial<{ [key in ConditionOperands]: MangoValue; }>
1304-
| Partial<{ [key in ArrayFieldOperands]: MangoValue[] }>
1305-
| Partial<{ [key in CombinationOperands]: MangoSelector[] }>
1306-
13071287
// http://docs.couchdb.org/en/latest/api/database/find.html#sort-syntax
13081288
type SortOrder = string | string[] | { [key: string]: 'asc' | 'desc' };
13091289

0 commit comments

Comments
 (0)