Skip to content

Commit 0802c95

Browse files
breaking change: move from surrealdb.node to surrealdb.js
1 parent f2c8fef commit 0802c95

9 files changed

+2706
-6044
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ client_generated/
9292
.tshy-build-tmp
9393
dist
9494
playground.ts
95+
out

README.md

+27-21
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1-
# SurrealDB Client & Zod Schema Generator
1+
# SurrealDB Client & Zod Schema Generator
22

33
SurrealDB Schema Generator is a handy tool that simplifies the process of generating [zod](http://zod.dev) schemas and TypeScript clients for [SurrealDB](http://surrealdb.com) based on your provided database schema.
44
Its primary purpose is to offer a fundamental starting point, not to replace a full-blown automated ORM.
55

6-
## Features
6+
## Features
77

8-
- Generate zod schemas and TypeScript clients for SurrealDB.
9-
- Utilize your existing database schema created with excellent tools like [surrealist.app](https://surrealist.app/).
10-
- Benefit from a user-friendly **Designer** in Surrealist to craft your data model effortlessly.
11-
- Export your schema from Surrealist and use it with this tool.
12-
- Choose to generate only zod schemas or include a basic TypeScript client.
13-
- Utilize zod schemas for [CIRQL](https://cirql.starlane.studio/) if needed.
8+
- Generate zod schemas and TypeScript clients for SurrealDB.
9+
- Utilize your existing database schema created with excellent tools like [surrealist.app](https://surrealist.app/).
10+
- Benefit from a user-friendly **Designer** in Surrealist to craft your data model effortlessly.
11+
- Export your schema from Surrealist and use it with this tool.
12+
- Choose to generate only zod schemas or include a basic TypeScript client.
13+
- Utilize zod schemas for [CIRQL](https://cirql.starlane.studio/) if needed.
1414

15-
## How It Works
15+
## 🚨 Warning Version 2.x
1616

17-
SurrealDB Schema Generator connects to your specified database and extracts the provided `DEFINE` information.
18-
Additionally, you can provide a SurrealQL file containing conditions.
19-
Before fetching the `DEFINE` information, the tool queries the SurrealDB instance using the conditions specified in the file.
17+
Version 2 has breaking changes!
18+
The tool now uses `surrealdb.js` instead of `surrealdb.node` for interacting with a SurrealDB instance.
2019

21-
**Please Note:**
22-
The information is not directly extracted from the provided file - it is written to the database in advance.
20+
The change was made, because it seems that `surrealdb.js` is closer to the SurrealDB development process and more up to date in general.
2321

24-
Enjoy using SurrealDB Schema Generator to streamline your schema generation process for SurrealDB and zod.
25-
It's designed to make your life easier when working with these powerful technologies.
22+
This means, the option "memory" for connections is no longer available, and you need to run against a real running SurrealDB instance (use docker).
23+
24+
## How It Works
25+
26+
1. SurrealDB Schema Generator connects to your specified database
27+
2. If you provide a surql schema file, the SurrealQL schema is written to the database
28+
3. The generator extracts the `DEFINE` information from the connected database
29+
4. Based on the definitions found in the database, the zod schemas are generated
30+
31+
Enjoy using SurrealDB Schema Generator to streamline your schema generation process for SurrealDB and zod.
32+
It's designed to make your life easier when working with these powerful technologies.
2633

2734
## Installation
2835

@@ -32,13 +39,13 @@ You can directly execute the generation:
3239
npx surql-gen
3340
```
3441

35-
Or you can install the generator as depenedency into your project.
42+
Or you can install the generator as dependency into your project.
3643

3744
```bash
3845
npm i -D @sebastianwessel/surql-gen
3946
```
40-
In case you install the generator as dependency or you installed it globally, you can call directly `surql-gen`
4147

48+
In case you install the generator as dependency or you installed it globally, you can call directly `surql-gen`
4249

4350
## How to Use
4451

@@ -65,8 +72,8 @@ Generate zod schema and typescript client code from running Surreal database
6572
Options:
6673
-V, --version output the version number
6774
-f, --schemaFile a SurrealQL file containing the definitions (default: myschema.surql)
68-
-c, --config config file (default: surql-gen.json)
69-
-s, --surreal SurrealDB connection url (default: memory)
75+
-c, --config config file (default: surql-gen.json)
76+
-s, --surreal SurrealDB connection url (default: http://localhost:8000)
7077
-u, --username auth username (default: root)
7178
-p, --password auth password (default: root)
7279
-n, --ns the namspace (default: test)
@@ -119,7 +126,6 @@ They serve as safe spaces for your customizations, changes, and enhancements:
119126
**Customization Freedom**: You can confidently make modifications and enhancements in these subfolders without worrying about them being altered by future executions of the tool.
120127
This design allows you to tailor the generated code to your project's specific requirements, ensuring a seamless development experience.
121128

122-
123129
---
124130

125131
If you like this tool, I please you, to give a star ⭐️ on github:

0 commit comments

Comments
 (0)