GithubHelp home page GithubHelp logo

rss-aggregator's Introduction

Introduction

This is a RSS feed aggregator, which is a web server that allow clients to:

  • Add RSS feeds to be collected
  • Follow and unfollow RSS feeds that other users have added
  • Fetch all of the latest posts from the RSS feeds they follow

You can use this project to keep up with your favorite blogs, news sites, podcasts, and more!

PostgreSQL

1. Install:

brew install postgresql

2. Check version:

psql --version

3. Start Postgres server in the background

brew services start postgresql

4. Connect to the server

Download and install pgAdmin. Then create a new server connection:

  • Host: localhost
  • Port: 5432
  • Username: postgres
  • Password: your password

5. Create and query a database

SELECT version();

sqlc and goose

1. Installation

brew install sqlc

Then run sqlc version to make sure it's installed correctly.

brew install goose

Then run goose -version to make sure it's installed correctly.

2. Migration using goose

I recommend creating an sql directory in the root of your project, and in there creating a schema directory.

A "migration" is a SQL file that describes a change to your database schema. For now, we need our first migration to create a users table. The simplest format for these files is:

-- +goose Up
CREATE TABLE ...

-- +goose Down
DROP TABLE users;

The -- +goose Up and -- +goose Down comments are required. They tell Goose how to run the migration. An "up" migration moves your database from its old state to a new state. A "down" migration moves your database from its new state back to its old state.

By running all of the "up" migrations on a blank database, you should end up with a database in a ready-to-use state. "Down" migrations are only used when you need to roll back a migration, or if you need to reset a local testing database to a known state.

Run the migration:

goose postgres protocol://username:password@host:port/database up

3. Configure sqlc

Create a file called sqlc.yaml in the root of the project.

version: "2"
sql:
  - schema: "sql/schema"
    queries: "sql/queries"
    engine: "postgresql"
    gen:
      go:
        out: "internal/database"

We're telling SQLC to look in the sql/schema directory for our schema structure (which is the same set of files that Goose uses, but sqlc automatically ignores "down" migrations), and in the sql/queries directory for queries. We're also telling it to generate Go code in the internal/database directory.

rss-aggregator's People

Contributors

rui-han 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.