@blitznocode/blitz-orm 0.10.31 → 0.11.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blitznocode/blitz-orm",
3
- "version": "0.10.31",
3
+ "version": "0.11.0",
4
4
  "author": "blitznocode.com",
5
5
  "description": "Blitz-orm is an Object Relational Mapper (ORM) for graph databases that uses a JSON query language called Blitz Query Language (BQL). BQL is similar to GraphQL but uses JSON instead of strings. This makes it easier to build dynamic queries.",
6
6
  "main": "dist/index.mjs",
@@ -36,8 +36,8 @@
36
36
  "object-traversal": "^1.0.1",
37
37
  "radash": "^12.1.0",
38
38
  "robot3": "^0.4.1",
39
- "surrealdb.js": "1.0.0-beta.8",
40
- "typedb-driver": "2.28.2-rc1",
39
+ "surrealdb.js": "1.0.0-beta.9",
40
+ "typedb-driver": "2.28.4",
41
41
  "uuid": "^9.0.1"
42
42
  },
43
43
  "devDependencies": {
@@ -86,11 +86,13 @@
86
86
  "test:ignoreTodo": "pnpm test:surrealdb-ignoreTodo && pnpm test:typedb-ignoreTodo && pnpm test:multidb",
87
87
  "test:multidb": "./tests/test.sh multidb",
88
88
  "test:query": "./tests/test.sh query.test.ts",
89
+ "test:surrealdb-ignoreTodo": "cross-env BORM_TEST_ADAPTER=surrealDB BORM_TEST_SURREALDB_LINK_MODE=refs ./tests/test.sh tests/unit/allTests.test.ts -t \"^(?!.*TODO{.*[S].*}:).*\"",
89
90
  "test:surrealdb-ignoreTodo:edges": "cross-env BORM_TEST_ADAPTER=surrealDB BORM_TEST_SURREALDB_LINK_MODE=edges ./tests/test.sh tests/unit -t \"^(?!.*TODO{.*[S].*}:).*\"",
90
- "test:surrealdb-ignoreTodo:refs": "cross-env BORM_TEST_ADAPTER=surrealDB BORM_TEST_SURREALDB_LINK_MODE=refs ./tests/test.sh tests/unit -t \"^(?!.*TODO{.*[S].*}:).*\"",
91
91
  "test:surrealdb-query:edges": "cross-env BORM_TEST_ADAPTER=surrealDB BORM_TEST_SURREALDB_LINK_MODE=edges ./tests/test.sh tests/unit/queries/query.test.ts",
92
92
  "test:surrealdb-query:refs": "cross-env BORM_TEST_ADAPTER=surrealDB BORM_TEST_SURREALDB_LINK_MODE=refs ./tests/test.sh tests/unit/queries/query.test.ts",
93
- "test:typedb-ignoreTodo": "cross-env BORM_TEST_ADAPTER=typeDB vitest run tests/unit -t \"^(?!.*TODO{.*[T].*}:).*\" ",
93
+ "test:surrealdb-mutation:edges": "cross-env BORM_TEST_ADAPTER=surrealDB BORM_TEST_SURREALDB_LINK_MODE=edges ./tests/test.sh tests/unit/mutations",
94
+ "test:surrealdb-mutation:refs": "cross-env BORM_TEST_ADAPTER=surrealDB BORM_TEST_SURREALDB_LINK_MODE=refs ./tests/test.sh tests/unit/mutations",
95
+ "test:typedb-ignoreTodo": "cross-env BORM_TEST_ADAPTER=typeDB vitest run tests/unit/allTests.test.ts -t \"^(?!.*TODO{.*[T].*}:).*\" ",
94
96
  "test:typedb-mutation": "cross-env BORM_TEST_ADAPTER=typeDB vitest run unit/mutations",
95
97
  "test:typedb-query": "cross-env BORM_TEST_ADAPTER=typeDB vitest run tests/unit/queries --watch",
96
98
  "test:typedb-schema": "cross-env BORM_TEST_ADAPTER=typeDB vitest run unit/schema",
package/readme.md CHANGED
@@ -1,19 +1,23 @@
1
1
  # Blitz-orm
2
+
2
3
  Blitz-orm is an Object Relational Mapper (ORM) for graph databases that uses a JSON query language called Blitz Query Language (BQL). BQL is similar to GraphQL but uses JSON instead of strings. This makes it easier to build dynamic queries.
3
4
 
4
5
  Blitz-orm is similar to other ORM packages such as Prisma. You define a BQL schema and it gets translated to different databases (currently only compatible with TypeDB but a dgraph adapter in the oven).
5
6
 
6
7
  ## Compatibility
7
- Currently, the only database that is compatible with Blitz-orm is TypeDB. The goal is to build adapters for other graph databases such as Dgraph and Neo4j, as well as classic databases like PostgreSQL and MongoDB in the future.
8
+
9
+ Currently, it works with TypeDB and surrealDB
8
10
 
9
11
  ## How to Use
12
+
10
13
  1. Install the package using your package manager, for example:
11
14
  `yarn add @blitznocode/blitz-orm`
12
15
  2. Create a Borm schema. You can find an example in the test folder.
13
16
  3. The borm.define() function is currently not working, so you will need to manually translate your BQL schema into a TypeQL schema (an example can be found in the test folder).
14
17
  4. Create a configuration file with the database name that you have created in TypeDB.
15
18
  5. Initialize Blitz-orm in a file like this:
16
- ```
19
+
20
+ ```ts
17
21
  import BormClient from '@blitznocode/blitz-orm';
18
22
 
19
23
  import { bormConfig } from './borm.config';
@@ -26,14 +30,19 @@ const bormClient = new BormClient({
26
30
 
27
31
  export default bormClient;
28
32
  ```
33
+
29
34
  6. You can then run queries and mutations like this:
30
- ```
35
+
36
+ ```ts
31
37
  const res = await bormClient.mutate({$entity: 'User', name: 'Ann'}, { noMetadata: true });
32
38
  ```
39
+
33
40
  ## Gotchas
41
+
34
42
  1) There is no borm.define() method yet. This means you will need to translate your borm schema into typeQL schema manually
35
43
  2) Private (non shared) attributes are defined in typeDB as "nameOfTheThing·nameOfTheAttribute", where "·" is a mid-do. As an example:
36
- ```
44
+
45
+ ```t
37
46
  #shared attribute (shared: true) :
38
47
  title sub attribute, value string;
39
48
  #as a private attribute (shared: false), default behaviour:
@@ -41,6 +50,7 @@ book·title sub attribute, value string;
41
50
  ```
42
51
 
43
52
  ## Documentation & example queries
53
+
44
54
  You can find example mutations and queries in the tests
45
55
  There is no official documentation but you can check the draft RFC:
46
56
  https://www.notion.so/blitzapps/BlitzORM-RFC-eb4a5e1464754cd7857734eabdeaa73c
@@ -48,33 +58,43 @@ https://www.notion.so/blitzapps/BlitzORM-RFC-eb4a5e1464754cd7857734eabdeaa73c
48
58
  The RFC includes future features and is not updated so please keep an eye on the query and mutation tests as those are designed for the features already working.
49
59
 
50
60
  ## How to Run TypeDB Locally
61
+
51
62
  To run TypeDB locally, follow the official instructions at https://docs.vaticle.com/docs/running-typedb/install-and-run. It is recommended to run TypeDB Studio, define the schema there, and test with pure TypeQL before using Blitz-orm.
52
63
 
53
64
  ## Collaboration & Contact
65
+
54
66
  You can contribute to the project by adding adapters for other databases, developing a BQL-to-GraphQL mapper, enhancing performance, or contributing to the public roadmap for this package (not yet published). To get in touch, please send an email to loic@blitznocode.com.
55
67
 
56
68
  ## Warning
69
+
57
70
  Blitz-orm is currently in alpha version and not ready for production use. Some key queries and mutations do work, but there is still much that needs to be done and performance improvements are needed. One of the biggest performance issues is with nested queries, as they currently require a call to TypeDB for each level of depth.
58
71
 
59
72
  ## What is Currently Working
73
+
60
74
  To see what is currently working and find examples, please check the test folder, where you will find a variety of queries and mutations.
61
75
 
62
76
  ## TypeGen
77
+
63
78
  This orm includes a basic typeGen that gets you types depending on the structure of the borm Schema. You can use it like this:
64
- ```
65
- type UserType = GenerateType<typeof typesSchema.relations.User>;
66
79
 
80
+ ```ts
81
+ type UserType = GenerateType<typeof typesSchema.relations.User>;
67
82
  ```
83
+
68
84
  Due to typescript limitations and also to be able to type fields from extended things, you will need to compile your bormSchema to a particular format. In order to make this work you can see the example that we have in the tests that you can run with `pnpm test:buildSchema`.
69
85
 
70
86
  You can also use it with your base schema without compiling but some fields might not be there and you might need to ignore some ts errors. Also you will need "as const" at the end of your schema.
71
87
 
72
88
  ## The future of this package
73
- - Achieve 100% compatibility with typeDB functions
74
- - Enhance functionality with new features such as, cardinality management, ordered attributes, Vectors (ordered relations)...
89
+
90
+ - Achieve 100% compatibility with typeDB and surrealDB
91
+ - Automatic schemas: Transform BQL schemas into any schema
92
+ - GraphQL compatibility
93
+ - Enhance functionality with new features such as ordered attributes, Vectors (ordered relations)...
75
94
  - Expand compatibility to other graph databases and traditional databases such as PostgreSQL or MongoDB
76
- - Enable the ability to split queries and mutations across multiple databases (for example, some data stored in PostgreSQL and other data in typeQL, all queried from a single point)
95
+ - Expand multidb compatibility, as now it is possible only for basic queries (querying data from two different DBs in a single BQL query)
77
96
 
78
97
  ## Development
98
+
79
99
  - We use pnpm as a package manager
80
100
  - You will need to add "-w", for instance `pnpm add -D husky -w`