Skip to content

Commit

Permalink
add code snippet for beginer easy to use
Browse files Browse the repository at this point in the history
Signed-off-by: seven <[email protected]>
  • Loading branch information
Blankll committed Mar 25, 2024
1 parent 23d349c commit b3d35e3
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>",
"license": "Apache-2.0",
Expand Down
93 changes: 93 additions & 0 deletions src/common/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}
`;
3 changes: 2 additions & 1 deletion src/views/editor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
buildSearchToken,
CustomError,
Decoration,
defaultCodeSnippet,
SearchToken,
searchTokensProvider,
} from '../../common';
Expand Down Expand Up @@ -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',
});
Expand Down

0 comments on commit b3d35e3

Please sign in to comment.