tasks

command
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

README

Tasks

an example http task microservice built with myjson

Details
  • 3 collections: account, user, task
  • tasks belong to users and users belong to accounts (foreign keys)
  • tasks & users have triggers to update their timestamps to now() on set/update/create
  • the first time the server is run, 100 accounts, 1000 users, and 3000 tasks will be seeded
  • http server configures the collections on startup
  • http server supports:
    • getting collection schemas
    • creating collection documents
    • updating collection documents
    • setting collection documents
    • deleting collection documents
    • querying collection documents

Starting the HTTP Server:

go run main.go

registered collections: [account cdc migration task user]
registered endpoint: [GET] /collections
registered endpoint: [POST] /collections/{collection}/documents
registered endpoint: [GET PUT PATCH DELETE] /collections/{collection}/documents/{id}
registered endpoint: [POST] /collections/{collection}/query
starting http server on port :8080

GET all accounts:

curl --location --request POST 'http://localhost:8080/collections/account/query' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
  "select": [{"field": "*"}]
}'

GET users belonging to an account:

curl --location --request POST 'http://localhost:8080/collections/user/query' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
  "select": [{"field": "*"}],
  "where": [{"field": "account_id", "op": "eq", "value": "$account"}],
  "limit": 10
}'

GET tasks belonging to a user:

curl --location --request POST 'http://localhost:8080/collections/task/query' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
  "select": [{"field": "*"}],
  "where": [{"field": "user", "op": "eq", "value": "$user"}]
}'

GET tasks joined to users:

curl --location --request POST 'http://localhost:8080/collections/task/query' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
  "select": [{"field": "user"}, {"field": "content"}, {"field": "usr.contact.email"}],
  "join": [{
      "collection": "user",
      "on": [{
        "field": "_id",
        "op": "eq",
        "value": "$user"
      }],
      "as": "usr"
  }],
  "limit": 10
}'

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL