Giter Site home page Giter Site logo

blogschema's Introduction

BlogSchema

This is an example of how easy it is to use Red and Raku to develop a DB schema for a simple blog. It does not serve or generates the blog's pages. It only creates the database schema and provides introspection into the database.

Usage:

  bin/blog.p6 create-db [--populate] -- Creates the database schema. If --populate, populates the DB with sample data.
  bin/blog.p6 new-person --name=<Str> -- Creates a new person
  bin/blog.p6 list-people -- Lists existent people
  bin/blog.p6 new-post --author=<Str> --title=<Str> [--publish] -- Creates a new post. Reads STDIN to get the post's body.
  bin/blog.p6 publish-post <post> -- Publishes a given post.
  bin/blog.p6 edit-post <post> [--author=<Str>] [--title=<Str>] [--tag=<Str>] -- Edits a given post.
  bin/blog.p6 list-posts [--tag=<Str>] [--published] -- Lists all the posts or all posts with a given tag. It can filter only the published posts.
  bin/blog.p6 comment --author=<Str> --post=<UInt> -- Adds a new comment.
  bin/blog.p6 list-comments --post=<UInt> -- Lists all comments. Filter by post.
  bin/blog.p6 list-comments --author=<Str> -- Lists all comments. Filter by author
  bin/blog.p6 create-tag <name> -- Creates a new tag
  bin/blog.p6 list-tags [--post=<UInt>] -- Lists all tags. Filter by post.
  bin/blog.p6 search-posts <key-word> [--published] -- Searches by a post.
  bin/blog.p6 get-config
  bin/blog.p6 get-config <key>
  bin/blog.p6 set-config <key> <value>

Models:

It uses a few models to describe a DB schema for a blog.

  • Person Describes a person, it could be a Post's author or a Comment's author.

  • Post Describes a post, it's related to Person through the author relationship, Comment through the comments relationship and a N-M relationship for Tag (using N-1 post-tags) called tags.

  • Tag Describes a tag. It has a N-M relationship (using N-1 post-tags) called posts.

  • Comment Describes a comment. It's related to a Post (post) and to a Person (author).

  • BlogConfig Stores pairs (key/value) with the blog's configuration.

It also has a script used to interact with the DB.

blogschema's People

Contributors

fco avatar

Stargazers

 avatar  avatar

Watchers

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