Giter Club home page Giter Club logo

svelte-electric-app's Introduction

Electric SQL and Svelte

This is an example webapp using svelte and electric sql.

git clone https://github.com/conorbergin/svelte-electric-app/
cd svelte-electric-app
npm i
npm run dev

The Backend

You only need to start the backend if you are trying to write directly to the sql database, or you want to sync data between instances.

You will need docker-compose v2, your distro might only have v1 in its repo, so check before installing.

cd backend
docker compose up

You then need to build the database using the sql in backend/migrations.sql, one way to do this is to copy and paste the commands into the psql command line. Install psql and run psql -h localhost -U postgres -p 65432 and enter the password proxy_password, if you want to change these values have a look at the backend/.envrc file.

You can then add data to the sql tables in psql using commands such as: INSERT INTO my_items (id, name) VALUES (gen_random_uuid(),"hello");.

Modifying

If you want to change the application you will need to define your own database. You can create a new postgres instance and create your own tables and electrify them using ALTER TABLE my_table ENABLE ELECTRIC; note that this will only work if the table has a uuid as a primary key.

After your databse is set up you need to generate the typescript client bindings using:

npx electric-sql generate

svelte-electric-app's People

Contributors

conorbergin avatar chrislasar 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.