mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 15:16:01 +00:00
mongo filter: empty array, not empty array
This commit is contained in:
@@ -44,6 +44,10 @@ const testCondition = (operator, value) => () => ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const multiTestCondition = condition => () => ({
|
||||||
|
__placeholder__: condition,
|
||||||
|
});
|
||||||
|
|
||||||
const compoudCondition = conditionType => conditions => {
|
const compoudCondition = conditionType => conditions => {
|
||||||
if (conditions.length == 1) return conditions[0];
|
if (conditions.length == 1) return conditions[0];
|
||||||
return {
|
return {
|
||||||
@@ -85,7 +89,15 @@ const createParser = () => {
|
|||||||
|
|
||||||
comma: () => word(','),
|
comma: () => word(','),
|
||||||
not: () => word('NOT'),
|
not: () => word('NOT'),
|
||||||
|
empty: () => word('EMPTY'),
|
||||||
|
array: () => word('ARRAY'),
|
||||||
notExists: r => r.not.then(r.exists).map(testCondition('$exists', false)),
|
notExists: r => r.not.then(r.exists).map(testCondition('$exists', false)),
|
||||||
|
notEmptyArray: r =>
|
||||||
|
r.not
|
||||||
|
.then(r.empty)
|
||||||
|
.then(r.array)
|
||||||
|
.map(multiTestCondition({ $exists: true, $type: 'array', $ne: [] })),
|
||||||
|
emptyArray: r => r.empty.then(r.array).map(multiTestCondition({ $exists: true, $eq: [] })),
|
||||||
exists: () => word('EXISTS').map(testCondition('$exists', true)),
|
exists: () => word('EXISTS').map(testCondition('$exists', true)),
|
||||||
true: () => word('TRUE').map(testCondition('$eq', true)),
|
true: () => word('TRUE').map(testCondition('$eq', true)),
|
||||||
false: () => word('FALSE').map(testCondition('$eq', false)),
|
false: () => word('FALSE').map(testCondition('$eq', false)),
|
||||||
@@ -117,6 +129,8 @@ const createParser = () => {
|
|||||||
r.gt,
|
r.gt,
|
||||||
r.le,
|
r.le,
|
||||||
r.ge,
|
r.ge,
|
||||||
|
r.notEmptyArray,
|
||||||
|
r.emptyArray,
|
||||||
r.startsWith,
|
r.startsWith,
|
||||||
r.endsWith,
|
r.endsWith,
|
||||||
r.contains,
|
r.contains,
|
||||||
|
|||||||
@@ -235,5 +235,6 @@
|
|||||||
bind:loadedRows
|
bind:loadedRows
|
||||||
bind:selectedCellsPublished
|
bind:selectedCellsPublished
|
||||||
frameSelection={!!macroPreview}
|
frameSelection={!!macroPreview}
|
||||||
|
onOpenQuery={openQuery}
|
||||||
{grider}
|
{grider}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -168,6 +168,8 @@
|
|||||||
{ onClick: () => openFilterWindow('<>'), text: 'Does Not Equal...' },
|
{ onClick: () => openFilterWindow('<>'), text: 'Does Not Equal...' },
|
||||||
{ onClick: () => setFilter('EXISTS'), text: 'Field exists' },
|
{ onClick: () => setFilter('EXISTS'), text: 'Field exists' },
|
||||||
{ onClick: () => setFilter('NOT EXISTS'), text: 'Field does not exist' },
|
{ onClick: () => setFilter('NOT EXISTS'), text: 'Field does not exist' },
|
||||||
|
{ onClick: () => setFilter('NOT EMPTY ARRAY'), text: 'Array is not empty' },
|
||||||
|
{ onClick: () => setFilter('EMPTY ARRAY'), text: 'Array is empty' },
|
||||||
{ onClick: () => openFilterWindow('>'), text: 'Greater Than...' },
|
{ onClick: () => openFilterWindow('>'), text: 'Greater Than...' },
|
||||||
{ onClick: () => openFilterWindow('>='), text: 'Greater Than Or Equal To...' },
|
{ onClick: () => openFilterWindow('>='), text: 'Greater Than Or Equal To...' },
|
||||||
{ onClick: () => openFilterWindow('<'), text: 'Less Than...' },
|
{ onClick: () => openFilterWindow('<'), text: 'Less Than...' },
|
||||||
|
|||||||
@@ -1634,6 +1634,9 @@
|
|||||||
{#if grider.editable}
|
{#if grider.editable}
|
||||||
<FormStyledButton value="Add document" on:click={addJsonDocument} />
|
<FormStyledButton value="Add document" on:click={addJsonDocument} />
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if onOpenQuery}
|
||||||
|
<FormStyledButton value="Open Query" on:click={onOpenQuery} />
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{:else if grider.errors && grider.errors.length > 0}
|
{:else if grider.errors && grider.errors.length > 0}
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user