diff --git a/package-lock.json b/package-lock.json index 03b924f..c26939b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "DocKit", - "version": "0.2.1", + "version": "0.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "DocKit", - "version": "0.2.1", + "version": "0.2.2", "license": "Apache-2.0", "dependencies": { "buffer": "^6.0.3", diff --git a/package.json b/package.json index 10fe7f9..8cd346d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "DocKit", "productName": "DocKit", "private": true, - "version": "0.2.1", + "version": "0.2.2", "description": "A faster, better and more stable NoSQL desktop tools", "author": "geekfun ", "license": "Apache-2.0", diff --git a/src/common/editor.ts b/src/common/editor.ts index 9634001..cf2a416 100644 --- a/src/common/editor.ts +++ b/src/common/editor.ts @@ -250,3 +250,96 @@ export const buildSearchToken = (lines: Array<{ lineNumber: number; lineContent: } as SearchToken; }); }; + +export const defaultCodeSnippet = ` +// Cluster Health +GET _cluster/health + +// Cluster State +GET _cluster/state + +// Nodes Info +GET _nodes/info + +// Create Index +PUT dockit_sample_index + +// Delete Index +DELETE dockit_sample_index + + +// Get Mapping +GET dockit_sample_index/_mapping + + +// Put Mapping +PUT dockit_sample_index/_mapping +{ + "properties": { + "name": { + "type": "text" + } + } +} + +// Aliases +POST _aliases +{ + "actions": [ + { + "add": { + "index": "dockit_sample_index", + "alias": "dockit_sample_index_alias" + } + } + ] +} + +// Indexing Documents +POST dockit_sample_index/_doc/1 +{ + "name": "Elasticsearch", + "category": "Search Engine" +} + +// Searching +POST dockit_sample_index/_search +{ + "query": { + "match": { + "name": "Elasticsearch" + } + } +} + +// Count +POST dockit_sample_index/_count +{ + "query": { + "term": { + "category.keyword": "Search Engine" + } + } +} + +// Get Document +GET dockit_sample_index/_doc/1 + +// Update Document +POST dockit_sample_index/_update/1 +{ + "doc": { + "category": "Search Engine" + } +} + +// Delete Document +DELETE dockit_sample_index/_doc/1 + + +// Bulk API +POST _bulk +{"index": {"_index": "dockit_sample_index", "_id": "1"}} +{"name": "Document 1"} +{"delete": {"_index": "dockit_sample_index", "_id": "2"}} +`; diff --git a/src/views/editor/index.vue b/src/views/editor/index.vue index 5714783..5089673 100644 --- a/src/views/editor/index.vue +++ b/src/views/editor/index.vue @@ -13,6 +13,7 @@ import { buildSearchToken, CustomError, Decoration, + defaultCodeSnippet, SearchToken, searchTokensProvider, } from '../../common'; @@ -185,7 +186,7 @@ const setupQueryEditor = (code: string) => { queryEditor = monaco.editor.create(queryEditorRef.value, { automaticLayout: true, theme: getEditorTheme(), - value: code, + value: code ? code : defaultCodeSnippet, language: 'search', });