mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
redis search keys
This commit is contained in:
parent
1b52a2a0fc
commit
fe277f5ffa
@ -176,8 +176,8 @@ module.exports = {
|
||||
},
|
||||
|
||||
loadKeys_meta: true,
|
||||
async loadKeys({ conid, database, root }) {
|
||||
return this.loadDataCore('loadKeys', { conid, database, root });
|
||||
async loadKeys({ conid, database, root, filter }) {
|
||||
return this.loadDataCore('loadKeys', { conid, database, root, filter });
|
||||
},
|
||||
|
||||
exportKeys_meta: true,
|
||||
|
@ -197,8 +197,8 @@ async function handleCollectionData({ msgid, options }) {
|
||||
return handleDriverDataCore(msgid, driver => driver.readCollection(systemConnection, options));
|
||||
}
|
||||
|
||||
async function handleLoadKeys({ msgid, root }) {
|
||||
return handleDriverDataCore(msgid, driver => driver.loadKeys(systemConnection, root));
|
||||
async function handleLoadKeys({ msgid, root, filter }) {
|
||||
return handleDriverDataCore(msgid, driver => driver.loadKeys(systemConnection, root, filter));
|
||||
}
|
||||
|
||||
async function handleExportKeys({ msgid, options }) {
|
||||
|
2
packages/types/engines.d.ts
vendored
2
packages/types/engines.d.ts
vendored
@ -89,7 +89,7 @@ export interface EngineDriver {
|
||||
name: string;
|
||||
}[]
|
||||
>;
|
||||
loadKeys(pool, root: string): Promise;
|
||||
loadKeys(pool, root: string, filter?: string): Promise;
|
||||
exportKeys(pool, options: {}): Promise;
|
||||
loadKeyInfo(pool, key): Promise;
|
||||
loadKeyTableRange(pool, key, cursor, count): Promise;
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
export let reloadToken = 0;
|
||||
export let connection;
|
||||
export let filter;
|
||||
|
||||
let reloadToken2 = 0;
|
||||
|
||||
let maxShowCount = SHOW_INCREMENT;
|
||||
@ -24,7 +26,7 @@
|
||||
// $: items = useDatabaseKeys({ conid, database, root, reloadToken });
|
||||
</script>
|
||||
|
||||
{#await apiCall('database-connections/load-keys', { conid, database, root, reloadToken, reloadToken2 })}
|
||||
{#await apiCall('database-connections/load-keys', { conid, database, root, filter, reloadToken, reloadToken2 })}
|
||||
<LoadingInfo message="Loading key list" wrapper />
|
||||
{:then items}
|
||||
{@const itemsSorted = _.sortBy(items || [], 'text')}
|
||||
@ -36,6 +38,7 @@
|
||||
{root}
|
||||
{connection}
|
||||
{item}
|
||||
{filter}
|
||||
{indentLevel}
|
||||
onRefreshParent={() => {
|
||||
reloadToken2 += 1;
|
||||
|
@ -53,7 +53,7 @@
|
||||
</script>
|
||||
|
||||
<SearchBoxWrapper>
|
||||
<SearchInput placeholder="Search keys" bind:value={filter} />
|
||||
<SearchInput placeholder="Search keys" bind:value={filter} isDebounced />
|
||||
<CloseSearchButton bind:filter />
|
||||
<InlineButton on:click={handleAddKey} title="Add new key">
|
||||
<FontIcon icon="icon plus-thick" />
|
||||
@ -63,5 +63,5 @@
|
||||
</InlineButton>
|
||||
</SearchBoxWrapper>
|
||||
<WidgetsInnerContainer>
|
||||
<DbKeysSubTree {conid} {database} root="" {reloadToken} connection={$currentDatabase?.connection} />
|
||||
<DbKeysSubTree {conid} {database} root="" {reloadToken} connection={$currentDatabase?.connection} {filter} />
|
||||
</WidgetsInnerContainer>
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
export let item;
|
||||
export let indentLevel = 0;
|
||||
export let filter;
|
||||
|
||||
export let onRefreshParent;
|
||||
|
||||
@ -170,5 +171,13 @@
|
||||
</div> -->
|
||||
|
||||
{#if isExpanded}
|
||||
<DbKeysSubTree {conid} {database} root={item.root} indentLevel={indentLevel + 1} {reloadToken} {connection} />
|
||||
<DbKeysSubTree
|
||||
{conid}
|
||||
{database}
|
||||
root={item.root}
|
||||
indentLevel={indentLevel + 1}
|
||||
{reloadToken}
|
||||
{connection}
|
||||
{filter}
|
||||
/>
|
||||
{/if}
|
||||
|
@ -5,6 +5,7 @@ const driverBase = require('../frontend/driver');
|
||||
const Analyser = require('./Analyser');
|
||||
const Redis = require('ioredis');
|
||||
const RedisDump = require('node-redis-dump2');
|
||||
const { filterName } = require('dbgate-tools');
|
||||
|
||||
function splitCommandLine(str) {
|
||||
let results = [];
|
||||
@ -162,9 +163,10 @@ const driver = {
|
||||
return _.range(16).map((index) => ({ name: `db${index}`, extInfo: info[`db${index}`], sortOrder: index }));
|
||||
},
|
||||
|
||||
async loadKeys(pool, root = '') {
|
||||
async loadKeys(pool, root = '', filter = null) {
|
||||
const keys = await this.getKeys(pool, root ? `${root}:*` : '*');
|
||||
const res = this.extractKeysFromLevel(root, keys);
|
||||
const keysFiltered = keys.filter((x) => filterName(filter, x));
|
||||
const res = this.extractKeysFromLevel(root, keysFiltered);
|
||||
await this.enrichKeyInfo(pool, res);
|
||||
return res;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user