Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated readme #2

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
schedule:
- cron: "7 7 * * *"
name: Rolling

jobs:
nightly:
runs-on: ubuntu-latest
Expand All @@ -22,6 +23,7 @@ jobs:
run: cargo generate-lockfile
- name: cargo test --locked
run: cargo test --locked --all-features --all-targets

update:
runs-on: ubuntu-latest
name: ubuntu / beta / updated
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
target
/home/runner/.cargo
key: ${{ steps.target-cache-restore.outputs.cache-primary-key }}

proptest:
runs-on: ubuntu-latest
name: ubuntu / stable
Expand All @@ -60,6 +61,7 @@ jobs:
key: stable-target
- name: cargo test --test proptest --locked -- --ignored
run: cargo test --locked --test proptest -- --ignored

# minimal:
# runs-on: ubuntu-latest
# name: ubuntu / stable / minimal-versions
Expand All @@ -77,6 +79,7 @@ jobs:
# run: cargo +nightly update -Zminimal-versions
# - name: cargo test
# run: cargo test --locked --all-features --all-targets
#
os-check:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / stable
Expand All @@ -99,6 +102,7 @@ jobs:
run: cargo generate-lockfile
- name: cargo test
run: cargo test --locked --all-features --all-targets

coverage:
runs-on: ubuntu-latest
name: ubuntu / stable / coverage
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

## surreal-id

The `surreal-id` crate offers a standardized way to create and validate IDs in your application for usage with SurrealDB. By defining the `NewId` trait, the crate streamlines the ID creation process, handling errors like malformed or empty IDs, and ensures consistency with associated table names. This also enables developers to serialize and deserialize custom ID types from SurrealDB whilst still retrieving the ID field for usage in your application, making it using custom ID types and logic with SurrealDB seamless.
The `surreal-id` crate offers a standardized way to create and validate IDs in your application for usage with SurrealDB. Using the `NewId` trait, the crate streamlines the ID type defining process with a blanket implementation of `new` that handles errors like malformed or empty IDs, and ensures consistency with associated table names and functionality with SurrealDB. This also enables developers to create custom IDs in their application layer and serialize and deserialize those types safely from SurrealDB, ensuring type safety and consistency throughout the app.

## Example

```rs
```rust
use serde::{Deserialize, Serialize};
use surreal_id::NewId;
use surrealdb::{opt::RecordId, sql::Id};
Expand All @@ -31,11 +31,11 @@ impl NewId for UserId {
}
```

> NOTE: For most use cases, most of the above code is boilerplate that could be eliminated with a procerdural macro, where the only thing specified is the table name.
> NOTE: For most use cases, most of the above code is boilerplate that could be eliminated with a procerdural macro, where the only thing specified is the table name. PRs welcome!

Now you can instantiate the `UserId` type using `new`, and use it in your struct with SurrealDB like so:

```rs
```rust
#[derive(Serialize, Deserialize)]
pub struct User {
id: UserId,
Expand Down
Loading