gocrud - 使用圖形操作簡化結構化數據的CRUD

jopen 9年前發布 | 11K 次閱讀 gocrud Google Go/Golang開發

Go庫簡化任意深度結構化數據的創建、更新和刪除。它讓構建 REST 服務更快和簡便。

This library is built to allow these properties for the data:

  1. Versioning: Keep track of all edits to the data, including deletion operations.
  2. Authorship: Be able to track who edited (/deleted) what.
  3. Retention: On deletion, only mark it as deleted. Never actually delete any data.
  4. </ol>

    The library makes it easy to have Parent-Child relationships, quite common in today’s CRUD operations. For e.g.

    - Posts created by User (User -> Post)
    - Comments on Posts (Post -> Comment)
    - Likes on Posts (Post -> Like)
    - Likes on Comments (Comment -> Like)

    And be able to traverse these relationships and retrieve all of the children, grandchildren etc. For e.g.(User -> Post -> [(Comment -> Like), Like])

    The library does this by utilizing Graph operations, but without using a Graph database. This means the library can be used to quickly build a Go backend to serve arbitrarily complex data, while still using your database of choice.

    This library supports both SQL and NoSQL databases including other datastores, namely

    1. Cassandra
    2. LevelDB
    3. Any SQL stores (via http://golang.org/pkg/database/sql/)
    4. PostGreSQL (thanks philips)
    5. Google Datastore
    6. RethinkDB (thanks dancannon)
    7. MongoDB (thanks wolfeidau)
    8. Any others as requested

    Note: To get all of these dependencies, rungo get github.com/manishrjain/gocrud/example/social.

    In fact, it exposes a simple interface for operations requiring databases, so you can easily add your favorite database (or request for addition).

    type Store interface {
      Init(dbtype string, tablename string)
      Commit(tablePrefix string, its []*x.Instruction) error
      IsNew(tablePrefix string, subject string) bool
      GetEntity(tablePrefix string, subject string) ([]x.Instruction, error)
    }

    The data is stored in a flat “tuple” format, to allow for horizontal scaling across machines in both SQL and NoSQL databases. Again, no data is ever deleted, to allow for log tracking all the changes.

    Example Usage

    Let's take a social backend as an example (based on social.go)

    • Users create posts
    • Other users like Posts
    • Other users comment on Posts
    • Other users like the comments
    • Other users comment on the comment (aka reply)
    • (Extra) Other users like the comment on the comment
    • (Extra) Other users comment on the like

    項目主頁:http://www.baiduhome.net/lib/view/home/1435497176466

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!