presidium-db-client-server 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ server.listen(5000, () => {
|
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
const sessionHt = new DiskHashTableClient({
|
|
27
|
-
serverUrl: "http://localhost:
|
|
27
|
+
serverUrl: "http://localhost:5000",
|
|
28
28
|
tableName: "Session",
|
|
29
29
|
})
|
|
30
30
|
|
|
@@ -38,6 +38,58 @@ const sessionJson = await sessionHt.get(accessToken)
|
|
|
38
38
|
await sessionHt.delete(accessToken)
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
Query with DiskSortedHashTableClient.
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
const DatabaseServer = require("presidium-db-client-server/DatabaseServer")
|
|
45
|
+
const DiskSortedHashTableClient = require("presidium-db-client-server/DiskSortedHashTableClient")
|
|
46
|
+
|
|
47
|
+
const server = new DatabaseServer({
|
|
48
|
+
databasePath: `${__dirname}/database`,
|
|
49
|
+
})
|
|
50
|
+
await server.init()
|
|
51
|
+
|
|
52
|
+
server.listen(5000, () => {
|
|
53
|
+
console.log("Database server listening on port 5000")
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const postHt = new DiskSortedHashTableClient({
|
|
57
|
+
serverUrl: "http://localhost:5000",
|
|
58
|
+
tableName: "Post",
|
|
59
|
+
sortValueType: "number",
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const post1 = {
|
|
63
|
+
id: "post-1",
|
|
64
|
+
images: ["/assets/post-1/image-1.jpg"],
|
|
65
|
+
content: "First post",
|
|
66
|
+
time: Date.now(),
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const post2 = {
|
|
70
|
+
id: "post-2",
|
|
71
|
+
images: ["/assets/post-2/image-2.jpg"],
|
|
72
|
+
content: "Second post",
|
|
73
|
+
time: Date.now(),
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const post3 = {
|
|
77
|
+
id: "post-3",
|
|
78
|
+
images: ["/assets/post-3/image-3.jpg"],
|
|
79
|
+
content: "Third post",
|
|
80
|
+
time: Date.now(),
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
await postHt.set(post1.id, JSON.stringify(post1), post1.time)
|
|
84
|
+
await postHt.set(post2.id, JSON.stringify(post2), post2.time)
|
|
85
|
+
await postHt.set(post3.id, JSON.stringify(post3), post3.time)
|
|
86
|
+
|
|
87
|
+
const myPosts = []
|
|
88
|
+
for await (const postJson of postHt.reverseIterator()) {
|
|
89
|
+
myPosts.push(JSON.parse(postJson))
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
41
93
|
## Docs
|
|
42
94
|
Coming soon.
|
|
43
95
|
|