Giter VIP home page Giter VIP logo

repoimpl's Introduction

repoimpl

Repositories, migrations and tests with model

We write the necessary model. The function writes table queries, repositories and tests for each model in the migrations folder.

Install

go get github.com/realtemirov/repoimpl

Repository

type User struct {
    Username string
    Password string
}

err := repoimpl.NewRepository(User{})
if err != nil {
    panic(err)
}

Repository implement CRUD to postgres database with sql package and creates interface storage

go run main.go

├─ repository
  ─ postgres
   ─ user.go - CRUD methods
  ─ storage.go - CRUD interfaces

Migrations

type User struct {
    Username string
    Password string
}

err := repoimpl.NewMigration(User{})
if err != nil {
    panic(err)
}

Creates migration_user.sql in the migrations folder

go run main.go
CREATE TABLE IF NOT EXITS "users" (
    "username" TEXT,
    "password" TEXT
);

If db is written tag it will be written by tag

type User struct {
    Username string `db:"user_name"`
    Password string `db:"pass_word"`
}

err := repoImpl.NewDBTable(User{})
if err != nil {
    panic(err)
}

migration_user.sql

CREATE TABLE IF NOT EXITS "users" (
    "user_name" TEXT,
    "pass_word" TEXT
);

repoimpl's People

Contributors

realtemirov avatar

Stargazers

 avatar Suyunov Jasurbek avatar Akhmad avatar Doniyor 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.