duckdb-tinyorm 1.0.9 → 1.0.10
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 +34 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
# DuckDB Tiny ORM
|
|
2
2
|
|
|
3
3
|
Usage:
|
|
4
|
-
```typescript
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
```typescript
|
|
7
6
|
|
|
8
7
|
import 'reflect-metadata';
|
|
8
|
+
import { DuckDbRepository, Entity, Repository, DataTypeDecorator, BaseRepository, Id } from 'duckdb-tinyorm';
|
|
9
9
|
|
|
10
10
|
@Entity
|
|
11
|
-
export class
|
|
12
|
-
|
|
13
|
-
@DataTypeDecorator('VARCHAR')
|
|
14
|
-
Name?: string = null;
|
|
11
|
+
export class Subject {
|
|
15
12
|
|
|
16
13
|
@Id()
|
|
17
14
|
@DataTypeDecorator('VARCHAR')
|
|
18
|
-
|
|
15
|
+
Id?: string = null;
|
|
19
16
|
|
|
20
17
|
@DataTypeDecorator('VARCHAR')
|
|
21
|
-
|
|
18
|
+
Name?: string = null;
|
|
19
|
+
|
|
22
20
|
|
|
23
21
|
@DataTypeDecorator('VARCHAR')
|
|
24
|
-
|
|
22
|
+
Description?: string = null;
|
|
23
|
+
|
|
25
24
|
|
|
26
25
|
@DataTypeDecorator('INT')
|
|
27
26
|
Year?: number = null;
|
|
28
27
|
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
@Repository(
|
|
32
|
-
class
|
|
30
|
+
@Repository(Subject)
|
|
31
|
+
class SubjectRepository extends BaseRepository<Subject, string> {
|
|
33
32
|
constructor() {
|
|
34
33
|
super(DuckDbRepository.getInstances());
|
|
35
34
|
}
|
|
@@ -37,33 +36,32 @@ class AmenityRepository extends BaseRepository<Amenity, string> {
|
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
async function test() {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
await
|
|
58
|
-
await
|
|
59
|
-
const result = await amenityRepository.findAll();
|
|
39
|
+
const subjectRepository = new SubjectRepository();
|
|
40
|
+
|
|
41
|
+
const subject1 = new Subject();
|
|
42
|
+
subject1.Name = "Java Basic";
|
|
43
|
+
subject1.Description = "Java Basic";
|
|
44
|
+
subject1.Year = 2024;
|
|
45
|
+
subject1.Id = "JB"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const subject2 = new Subject();
|
|
49
|
+
subject2.Name = "Java OOP";
|
|
50
|
+
subject2.Description = "Java Object Oriented Programming";
|
|
51
|
+
subject2.Year = 2024;
|
|
52
|
+
subject2.Id = "OOP"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
await subjectRepository.save(subject1);
|
|
56
|
+
await subjectRepository.save(subject2);
|
|
57
|
+
const result = await subjectRepository.findAll();
|
|
60
58
|
console.table(result);
|
|
61
|
-
const
|
|
62
|
-
console.info(
|
|
63
|
-
const
|
|
64
|
-
console.info(
|
|
59
|
+
const subjectFound1:Subject = await subjectRepository.findById("JB");
|
|
60
|
+
console.info(subjectFound1);
|
|
61
|
+
const subjectFound2: Subject = await subjectRepository.findById("OOP");
|
|
62
|
+
console.info(subjectFound2);
|
|
65
63
|
|
|
66
|
-
const amenities = await
|
|
64
|
+
const amenities = await subjectRepository.findBy({Year: 2024}, ["Year"]);
|
|
67
65
|
console.table(amenities);
|
|
68
66
|
}
|
|
69
67
|
|