-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
84 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
import { Client } from "../mod.ts"; | ||
import { v4 } from "https://deno.land/[email protected]/uuid/mod.ts"; | ||
|
||
const client = new Client(); | ||
|
||
await client.connect("http://localhost:9200/"); | ||
|
||
const ajax = async () => { | ||
const count = async () => { | ||
try { | ||
const names = await client.count({ | ||
index: "myindex2", | ||
method: "post", | ||
}); | ||
console.log(names); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
const create = async () => { | ||
try { | ||
const id = v4.generate(); | ||
const names = await client.create({ | ||
index: "myindex2", | ||
id, | ||
body: { | ||
deleted: false, | ||
// _id: '6058046316761d2e8752aa4c44', | ||
_name: "hahs", | ||
title: "倚天屠龙记4", | ||
content: "剑心通明4", | ||
userId: "41", | ||
isSecret: false, | ||
group: "中国", | ||
contentText: "剑心通明4", | ||
titleText: "倚天屠龙记4", | ||
id: "6058046316761d2e8752aa4c", | ||
}, | ||
}); | ||
console.log(names); | ||
} catch (error) { | ||
console.error(error); | ||
|
@@ -19,5 +44,10 @@ const ajax = async () => { | |
|
||
console.time("ajax"); | ||
// await Array.from(new Array(100)).map(ajax); | ||
await ajax(); | ||
// await create(); | ||
await count(); | ||
|
||
setTimeout(async () => { | ||
await create(); | ||
}, 1000); | ||
console.timeEnd("ajax"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters