Skip to content

Commit 9ae93ba

Browse files
committed
add README, LICENSE, CONTRIBUTING
1 parent 50fe6a1 commit 9ae93ba

File tree

3 files changed

+149
-0
lines changed

3 files changed

+149
-0
lines changed

CONTRIBUTING.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Contribution
2+
3+
Feel free to open issues.
4+
5+
Before contributing code changes, see the [development guidelines](https://rorm.rs/developer/guidelines).

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 WebFreak
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# DORM
2+
3+
![License](https://img.shields.io/github/license/rorm-orm/dorm?label=License)
4+
5+
A sophisticated D ORM using [rorm-lib](https://github.com/rorm-orm/rorm-lib) as a backend.
6+
7+
Works standalone using multi-threading or with vibe-core.
8+
9+
The following databases are currently supported:
10+
- SQLite 3
11+
- MariaDB 10.5 - 10.9
12+
- Postgres 11 - 15
13+
14+
## Documentation
15+
16+
Take a look at [rorm-orm/docs](https://github.com/rorm-orm/docs) or just use the
17+
deployed documentation: [rorm.rs](https://rorm.rs).
18+
19+
Auto-generated source code documentation is available on [https://dorm.dpldocs.info/](https://dorm.dpldocs.info/).
20+
21+
## Installation
22+
23+
```
24+
dub add dorm
25+
```
26+
27+
When first compiling, DORM will automatically download pre-compiled library binaries into the package location when it hasn't been downloaded yet. You can also manually put the `librorm.a` (Posix) or `rorm.lib` (Windows) file into the DUB package to not make it download anything.
28+
29+
You can use `dub run dorm` to run the supporting CLI tool, which will be downloaded at the same time. `rorm-cli` is used for creating migrations, which you check-in into your project source and to apply migrations both on development machines as well as on production machines.
30+
31+
## Example
32+
33+
For a more detailed walkthrough see [rorm.rs](https://rorm.rs)
34+
35+
```d
36+
module models;
37+
38+
import dorm.design;
39+
40+
mixin RegisterModels;
41+
42+
class User : Model
43+
{
44+
@Id long id;
45+
46+
@maxLength(255)
47+
string username;
48+
49+
@maxLength(255)
50+
string password;
51+
52+
@autoCreateTime
53+
SysTime createdAt;
54+
55+
@columnName("admin")
56+
bool isAdmin;
57+
58+
@constructValue!(() => Clock.currTime + 24.hours)
59+
SysTime tempPasswordTime;
60+
}
61+
```
62+
63+
```d
64+
import models;
65+
66+
import faked, std.datetime.systime, std.random, std.stdio;
67+
68+
import dorm.api.db;
69+
70+
mixin SetupDormRuntime;
71+
72+
void main() {
73+
@DormPatch!User
74+
struct UserSelection {
75+
long id;
76+
string username;
77+
SysTime createdAt;
78+
}
79+
80+
DBConnectOptions options = {
81+
backend: DBBackend.SQLite,
82+
name: "database.sqlite3"
83+
};
84+
auto db = DormDB(options);
85+
86+
auto f = new Faker_de(uniform!int);
87+
88+
foreach (i; 0 .. 2) {
89+
@DormPatch!User
90+
struct UserInsert {
91+
string username;
92+
string password;
93+
bool isAdmin;
94+
}
95+
96+
UserInsert user;
97+
user.username = f.nameName;
98+
user.password = "123456";
99+
db.insert(user);
100+
}
101+
102+
auto oldestUsers = db.select!UserSelection
103+
.condition(u => u.not.isAdmin)
104+
.orderBy(u => u.createdAt.asc)
105+
.limit(5)
106+
.stream();
107+
108+
writeln("Oldest 5 Users:");
109+
foreach (i, user; oldestUsers) {
110+
writefln!"#%d %s\tcreated at %s"(i + 1, user.username, user.createdAt);
111+
112+
// delete first user
113+
if (i == 0)
114+
db.remove(user);
115+
}
116+
}
117+
```
118+
119+
For a more detailed walkthrough see [rorm.rs](https://rorm.rs)
120+
121+
## Contribution
122+
123+
Before contribution, see the [development guidelines](https://rorm.rs/developer/guidelines).

0 commit comments

Comments
 (0)