Giter VIP home page Giter VIP logo

surrealize's Introduction

๐Ÿšง๐Ÿšง๐Ÿšง๐Ÿšง This Project is Under Development ๐Ÿšง๐Ÿšง๐Ÿšง๐Ÿšง

Surrealize

Surrealize is a versatile client designed to interact seamlessly with SurrealDB, providing an intuitive interface to harness the power of SurrealDB's features. This client empowers developers to effortlessly integrate SurrealDB into their applications and projects.

Surrealize is inspired from TypeORM design

Overview

Surrealize simplifies the interaction with SurrealDB, a cutting-edge database designed for modern applications. With Surrealize, you can leverage the advanced capabilities of SurrealDB without the complexity.

Usage

use surrealize::sql::Thing;
use surrealize::data_store::DataStore;
use surrealize::model::Model;
use surrealize::opts::{ ConnectionOptions, On};
use serde::{Serialize, Deserialize};

struct User {
    id: Option<Thing>,
    username: String,
    email: String,
    password: String,
}

#[tokio::main]
async fn main() {
    // Set up connection options
    let connection_options = opts::ConnectionOptions {
        connection_url: "127.0.0.1:8000",
        auth: None,
        on: On {
            namespace: "development",
            database: "testing",
        }
        .into(),
    };

    // Initialize data store and register the User model
    let data_store = DataStore::init(connection_options)
        .await
        .expect("Failed to initialize DataStore")
        .register_model(Model::<User>::new());


    let new_user = User {
        id: None, 
        username: "john_doe".to_owned(),
        email: "[email protected]".to_owned(),
        password: "secure_password".to_owned(),
    };

    // Access the repository for the User model
    let user_repo = data_store.get_repository::<User>().unwrap();

    // Create the user in the database
    let created_user_entry = user_repo.create(new_user.clone()).await.expect("Failed to create user");
    let created_user = created_user_entry.data();

    // Output the created user details
    println!("User created successfully:");
    println!("ID: {:?}", created_user.id);
    println!("Username: {}", created_user.username);
    println!("Email: {}", created_user.email);
}

surrealize's People

Contributors

golok727 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.