idb-ts 3.0.0 β 3.0.1
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 +36 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
# idb-ts
|
|
1
|
+
# π idb-ts
|
|
2
2
|
|
|
3
|
-
##
|
|
4
|
-
|
|
3
|
+
## π Introduction
|
|
4
|
+
**idb-ts** is a lightweight, declarative, and type-safe way to work with IndexedDB using TypeScript. Effortlessly perform CRUD operations on your database with clean, structured code! π₯
|
|
5
|
+
|
|
6
|
+
## π¦ Installation
|
|
7
|
+
Install via npm and start using IndexedDB like a pro! β‘
|
|
8
|
+
```sh
|
|
5
9
|
npm i idb-ts
|
|
6
10
|
```
|
|
7
11
|
|
|
8
|
-
##
|
|
12
|
+
## β¨ Features
|
|
13
|
+
- β
**Declarative & Type-Safe** - Define your data models with decorators.
|
|
14
|
+
- β‘ **Easy CRUD Operations** - Perform create, read, update, and delete seamlessly.
|
|
15
|
+
- π **Fully Typed API** - Benefit from TypeScriptβs powerful type system.
|
|
16
|
+
- ποΈ **Performance Optimized** - Minimal overhead with IndexedDB's native capabilities.
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## π Example Usage
|
|
21
|
+
|
|
22
|
+
### ποΈ Declaring Entities
|
|
23
|
+
Use decorators to define your data models with automatic schema management.
|
|
12
24
|
|
|
25
|
+
```typescript
|
|
13
26
|
@DataClass()
|
|
14
27
|
class User {
|
|
15
28
|
@KeyPath()
|
|
@@ -41,8 +54,10 @@ class Location {
|
|
|
41
54
|
}
|
|
42
55
|
```
|
|
43
56
|
|
|
44
|
-
### CRUD
|
|
45
|
-
|
|
57
|
+
### π CRUD Operations
|
|
58
|
+
Perform database operations in an intuitive way:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
46
61
|
const db = await Database.build("idb-crud", [User, Location]);
|
|
47
62
|
|
|
48
63
|
const alice = new User("Alice", 25, "123 Main St");
|
|
@@ -52,25 +67,30 @@ await db.create(User, alice);
|
|
|
52
67
|
await db.create(Location, nyc);
|
|
53
68
|
|
|
54
69
|
const readAlice = await db.read(User, "Alice");
|
|
55
|
-
console.log("Read user:", readAlice);
|
|
70
|
+
console.log("π€ Read user:", readAlice);
|
|
56
71
|
|
|
57
72
|
alice.age = 26;
|
|
58
73
|
alice.address = "789 Maple St";
|
|
59
74
|
await db.update(User, alice);
|
|
60
75
|
|
|
61
76
|
const users = await db.list(User);
|
|
62
|
-
console.log("All users:", users);
|
|
77
|
+
console.log("π All users:", users);
|
|
63
78
|
|
|
64
79
|
await db.delete(User, "Alice");
|
|
65
|
-
console.log("User Alice deleted.");
|
|
80
|
+
console.log("β User Alice deleted.");
|
|
66
81
|
|
|
67
82
|
const remainingUsers = await db.list(User);
|
|
68
|
-
console.log("Remaining users:", remainingUsers);
|
|
83
|
+
console.log("π Remaining users:", remainingUsers);
|
|
69
84
|
|
|
70
85
|
const locations = await db.list(Location);
|
|
71
|
-
console.log("All locations:", locations);
|
|
86
|
+
console.log("π All locations:", locations);
|
|
72
87
|
```
|
|
73
88
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## π Useful Links
|
|
92
|
+
- π **GitHub**: [maifeeulasad/idb-ts](https://github.com/maifeeulasad/idb-ts)
|
|
93
|
+
- π¦ **NPM**: [idb-ts](https://www.npmjs.com/package/idb-ts)
|
|
94
|
+
|
|
95
|
+
π **Enjoy seamless IndexedDB integration with TypeScript! Happy coding!** π
|
|
96
|
+
|