GithubHelp home page GithubHelp logo

legwork's Introduction

legwork

A simple command line tool written in Go to perform PosgreSQL Full Text search.

NOTE: Make sure you have installed Go locally.

Setup database

Install Postgres:

$ brew install postgresql
$ brew services start postgresql

Create DB

$ createdb DB_NAME

Create PG extension

$ psql -h -d DB_NAME -U DB_USER -c 'CREATE EXTENSION if not exists "uuid-ossp"'

Setting up

$ git clone [email protected]:atifh/legwork.git
$ cd legwork
$ cp application.yml.sample application.yml

Note: Please update DB credentials in the application.yml file.

$ go install
$ go build main.go
$ ./main
./main
Applying database migrations!
Ran all migrations
How many users do you want to auto create? (5, 10 ..) >> 5
Creating 5 dummy users
New User ID is: 76eadef2-6267-4f29-8159-fe1108bf2659
tvs vector updated for User ID: 76eadef2-6267-4f29-8159-fe1108bf2659
New User ID is: bc0a1abb-f5e6-4264-afb8-b700a892e0e5
tvs vector updated for User ID: bc0a1abb-f5e6-4264-afb8-b700a892e0e5
New User ID is: 2ea798b4-ec34-41c8-9dc9-56c000bc11df
tvs vector updated for User ID: 2ea798b4-ec34-41c8-9dc9-56c000bc11df
New User ID is: 48eb77bd-2f02-4efe-8a9f-020dd048b000
tvs vector updated for User ID: 48eb77bd-2f02-4efe-8a9f-020dd048b000
New User ID is: d87e8f5a-264a-428f-a15a-acd2a9d7801e
tvs vector updated for User ID: d87e8f5a-264a-428f-a15a-acd2a9d7801e

5 Users in the DB

[
    {
        "Bio": "The sun set; the dusk fell on the stream, and lights began to appear along the shore. The Chapman light–house, a three–legged thing erect on a mud–flat, shone strongly.",
        "Email": "[email protected]",
        "ID": "76eadef2-6267-4f29-8159-fe1108bf2659",
        "Location": "Plympton",
        "Name": "Collarlinen"
    },
    {
        "Bio": "He completely abandoned the child of his marriage with Adelaida Ivanovna, not from malice, nor because of his matrimoni- al grievances, but simply because he forgot him.",
        "Email": "[email protected]",
        "ID": "bc0a1abb-f5e6-4264-afb8-b700a892e0e5",
        "Location": "San Martin",
        "Name": "Vipernotch"
    },
    {
        "Bio": "I am all in a sea of wonders. I doubt; I fear; I think strange things, which I dare not confess to my own soul. God keep me, if only for the sake of those dear to me!",
        "Email": "[email protected]",
        "ID": "2ea798b4-ec34-41c8-9dc9-56c000bc11df",
        "Location": "Plympton",
        "Name": "Bowfire"
    },
    {
        "Bio": "Then followed a battle of looks between them, but the captain soon knuckled under, put up his weapon, and resumed his seat, grumbling like a beaten dog.",
        "Email": "[email protected]",
        "ID": "48eb77bd-2f02-4efe-8a9f-020dd048b000",
        "Location": "Plympton",
        "Name": "Carpetsatin"
    },
    {
        "Bio": "Then followed a battle of looks between them, but the captain soon knuckled under, put up his weapon, and resumed his seat, grumbling like a beaten dog.",
        "Email": "[email protected]",
        "ID": "d87e8f5a-264a-428f-a15a-acd2a9d7801e",
        "Location": "Baldock",
        "Name": "Sargentclover"
    }
]
Enter any text to search users: >> dusk Chapman


Found 1 Search Results for dusk Chapman


[
    {
        "Bio": "The sun set; the dusk fell on the stream, and lights began to appear along the shore. The Chapman light–house, a three–legged thing erect on a mud–flat, shone strongly.",
        "Email": "[email protected]",
        "ID": "76eadef2-6267-4f29-8159-fe1108bf2659",
        "Location": "Plympton",
        "Name": "Collarlinen"
    }
]
Closing DB!

TODO

  • Setup env configs and build DB connection
  • Create table (User) with columns (name, bio, age, location, id as UUID)
  • Write a function that creates dummy users on demand
  • Main file should run as CMD which shows the total count of user available in the DB and further takes free text as input and finds users from the User table based on the matches.

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.