Skip to content

Commit

Permalink
refactor: no mames
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyko committed Oct 6, 2023
1 parent 4a6c1c0 commit cdef1a7
Show file tree
Hide file tree
Showing 46 changed files with 1,610 additions and 1,239 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 15 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["example", "scyllax-cli", "scyllax-macros", "scyllax-parser"]
members = ["example", "scyllax-cli", "scyllax-macros", "scyllax-macros-core", "scyllax-parser"]
resolver = "2"

[workspace.package]
Expand All @@ -19,27 +19,30 @@ readme = "README.md"
name = "scyllax"
readme = "README.md"
description = "A SQLx and Discord inspired query system for Scylla"
version = { workspace = true }
license = { workspace = true }
edition = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
version.workspace = true
license.workspace = true
edition.workspace = true
authors.workspace = true
repository.workspace = true
homepage.workspace = true

[dependencies]
anyhow = { workspace = true }
anyhow.workspace = true
async-trait = "0.1"
getrandom = "0.2"
mac_address = "1"
once_cell = "1"
scylla = { workspace = true }
scylla.workspace = true
scyllax-macros = { version = "0.1.8-alpha", path = "./scyllax-macros" }
scyllax-macros-core = { version = "0.1.8-alpha", path = "./scyllax-macros-core" }
thiserror = "1"
tracing = { workspace = true }
uuid = { workspace = true }
tracing.workspace = true
uuid.workspace = true

[workspace.dependencies]
scyllax-macros = { verison = "0.1.8-alpha", path = "scyllax-macros" }
scyllax-macros = { verison = "0.1.8-alpha", path = "./scyllax-macros" }
scyllax-macros-core = { verison = "0.1.8-alpha", path = "./scyllax-macros-core" }
scyllax-parser = { verison = "0.1.8-alpha", path = "./scyllax-parser" }
anyhow = "1"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt", "json", "tracing-log", "parking_lot"] }
Expand Down
3 changes: 1 addition & 2 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,5 @@ command = "cargo"
args = ["audit"]

[tasks.dev-book]
cwd = "book"
command = "mdbook"
args = ["serve"]
args = ["serve", "book"]
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ pub struct PersonEntity {
pub created_at: i64,
}
```
### 2. Select queries
With the [`select_query`] attribute, it's easy to define select queries.
### 2. Read queries
With the [`read_query`] attribute, it's easy to define select queries.
```rust,ignore
#[select_query(
query = "select * from person where id = ? limit 1",
entity_type = "PersonEntity"
#[read_query(
query = "select * from person where id = :id limit 1",
return_type = "PersonEntity"
)]
pub struct GetPersonById {
pub id: Uuid,
Expand All @@ -42,11 +42,10 @@ pub struct PersonEntity {
```

## Features
- [x] Select Queries
- [x] Upsert Queries (https://github.com/trufflehq/scyllax/pull/1)
- [x] Delete Queries
- [x] Read Queries
- [x] Write Queries (https://github.com/trufflehq/scyllax/pull/1)
- [ ] Request Coalescing
- [ ] Compile-time Select Query Validation
- [x] Compile-time Select Query Validation
- ensure the where constraints exist on the struct
- ensure the where constraints are the same type as the struct
- [ ] Runtime Query Validation (structure matches schema)
Expand Down
2 changes: 1 addition & 1 deletion book/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ fn main() {
let default_keyspace = std::env::var("SCYLLA_DEFAULT_KEYSPACE").ok();

let session = create_session(known_nodes, default_keyspace).await?;
let executor = Executor::with_session(session);
let executor = Executor::<UserQueries>::new(session).await?;
}
```
2 changes: 2 additions & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
- [Select Queries](./select_queries/README.md)
- [Delete Queries](./delete_queries/README.md)
- [Upsert Queries](./upsert_queries/README.md)
- [Query Collections](./query_collections/README.md)
- [Example](./example/README.md)
4 changes: 2 additions & 2 deletions book/src/delete_queries/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Delete Queries
Writing delete queries, which is pretty much the same as [Select Queries](../select_queries/index.html), is incredibly easy with the `delete_query` macro.

Simply create a struct with the fields you want to select, and annotate it with the `#[delete_query]` macro.
Simply create a struct with the fields you want to select, and annotate it with the `#[write_query]` macro.

```rust
#use scyllax::prelude::*;
Expand All @@ -15,7 +15,7 @@ Simply create a struct with the fields you want to select, and annotate it with
# pub created_at: i64,
#}
#
#[delete_query(
#[write_query(
query = "delete from person where id = ?",
entity_type = "PersonEntity"
)]
Expand Down
4 changes: 4 additions & 0 deletions book/src/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Example
Are you looking for a real-life example of scyllax? You're in luck! The `exmaple` directory in our GitHub repository contains a full example of scyllax in action -- it's actually used to run tests!

[https://github.com/trufflehq/scyllax/tree/main/example](https://github.com/trufflehq/scyllax/tree/main/example)
33 changes: 33 additions & 0 deletions book/src/query_collections/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Query Collections
Once you've made all your queries, you'll have to make a Query Collection. This is a struct that contains all your prepared queries. Scyllax provides the `create_query_collection` macro to make this easy.

```rust
use scyllax::prelude::*;
use super::model::UpsertPerson;

create_query_collection!(
PersonQueries,
[
GetPersonById,
GetPeopleByIds,
GetPersonByEmail,
DeletePersonById,
UpsertPerson,
]
);
```
Then, you use the Query Collection when you instantiate your Executor.

```rust
let executor = Executor::<PersonQueries>::new(session).await?;
```

Finally, you can run your queries.

```rust
let person = executor
.execute_read(&GetPersonById {
id: Uuid::new_v4(),
})
.await?;
```
2 changes: 1 addition & 1 deletion book/src/select_queries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Simply create a struct with the fields you want to select, and annotate it with
# pub created_at: i64,
#}
#
#[select_query(
#[read_query(
query = "select * from person where id = ? limit 1",
entity_type = "PersonEntity"
)]
Expand Down
28 changes: 14 additions & 14 deletions example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[package]
name = "example"
description = "an example using scyllax"
version = { workspace = true }
license = { workspace = true }
edition = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
version.workspace = true
license.workspace = true
edition.workspace = true
authors.workspace = true
repository.workspace = true
homepage.workspace = true
publish = false

[dependencies]
anyhow = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
scylla = { workspace = true }
anyhow.workspace = true
serde.workspace = true
serde_json.workspace = true
scylla.workspace = true
scyllax = { path = "../" }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
uuid = { workspace = true }
tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
uuid.workspace = true

[features]
default = ["integration"]
Expand Down
Loading

0 comments on commit cdef1a7

Please sign in to comment.