/
index.spec.ts
39 lines (36 loc) · 1.34 KB
/
index.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import OracleORDSClient from "oracle-ords-client"
import fs from "fs"
import { randomUUID } from "crypto"
const oracleORDSClient = new OracleORDSClient({
"client_id": process.env["client_id"]!,
"client_secret": process.env["client_secret"]!,
"schema": process.env["schema"]!,
"ords_url": process.env["client_secret"]!,
})
const path = randomUUID()
describe("oracle ords client", () => {
it("", async () => {
// 4,367,406 bytes (4.4 MB) max image size
const blob = fs.readFileSync("./m8.png")
const item = await oracleORDSClient.putJSONDocument("IMAGE", {
path,
blob: JSON.stringify(blob)
})
console.log("put", item)
const query = new URLSearchParams()
query.append('action', 'query')
query.append('fields', 'all')
query.append('limit', '1')
query.append('totalResults', 'false')
let collection = await oracleORDSClient.queryJSONDocument("IMAGE", query, {
path
})
console.log("query", collection.items[0].value)
const result = await oracleORDSClient.deleteJSONObject("IMAGE", item.id)
console.log("delete", result)
collection = await oracleORDSClient.queryJSONDocument("IMAGE", query, {
path
})
console.log("query should be empty", collection)
})
})