couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From glynnb...@apache.org
Subject [couchdb-nano] branch master updated: fix(nano.d.ts): fix MangoSelector typings (#172)
Date Thu, 04 Jul 2019 11:34:34 GMT
This is an automated email from the ASF dual-hosted git repository.

glynnbird pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git


The following commit(s) were added to refs/heads/master by this push:
     new b080a48  fix(nano.d.ts): fix MangoSelector typings (#172)
b080a48 is described below

commit b080a4858876c2d778aba0907ab1445281c2347b
Author: ilatovsky <ailatovsky@gmail.com>
AuthorDate: Thu Jul 4 14:34:29 2019 +0300

    fix(nano.d.ts): fix MangoSelector typings (#172)
---
 lib/nano.d.ts | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/lib/nano.d.ts b/lib/nano.d.ts
index 31b60d3..506ecaa 100644
--- a/lib/nano.d.ts
+++ b/lib/nano.d.ts
@@ -1197,10 +1197,33 @@ declare namespace nano {
   type MangoValue = number | string | Date | boolean | null;
 
   // http://docs.couchdb.org/en/latest/api/database/find.html#selector-syntax
-  interface MangoSelector {
-    [key: string]: MangoSelector | MangoValue | MangoValue[];
+
+  enum ConditionOperands {
+    $lt = '$lt',
+    $lte = '$lte',
+    $eq = '$eq',
+    $ne = '$ne',
+    $gte = '$gte',
+    $gt = '$gt'
+  }
+
+  enum ArrayFieldOperands {
+    $in = '$in',
+    $nin = '$nin'
   }
 
+  enum CombinationOperands {
+      $or = '$or',
+      $and = '$and',
+      $nor = '$nor',
+      $all = '$all'
+  }
+
+  type MangoSelector = { [key: string]: MangoSelector | MangoValue | MangoValue[]; }
+    | Partial<{ [key in ConditionOperands]: MangoValue; }>
+    | Partial<{ [key in ArrayFieldOperands]: MangoValue[] }>
+    | Partial<{ [key in CombinationOperands]: MangoSelector[] }>
+
   // http://docs.couchdb.org/en/latest/api/database/find.html#sort-syntax
   type SortOrder = string | string[] | { [key: string]: 'asc' | 'desc' };
 


Mime
View raw message