database

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Example (RespDBlist_json)
display.Print(
	&respDBList{Info: []*types.DatasetIdentifier{
		{
			Name:  "db_a",
			Owner: mustDecodeBase64("b3duZXI="),
			DBID:  "xabc",
		},
		{
			Name:  "db_b",
			Owner: mustDecodeBase64("b3duZXI="),
			DBID:  "xdef",
		},
	}},
	nil, "json")
Output:

{
  "result": [
    {
      "name": "db_a",
      "owner": "b3duZXI=",
      "dbid": "xabc"
    },
    {
      "name": "db_b",
      "owner": "b3duZXI=",
      "dbid": "xdef"
    }
  ],
  "error": ""
}
Example (RespDBlist_text)
display.Print(
	&respDBList{Info: []*types.DatasetIdentifier{
		{
			Name:  "db_a",
			Owner: mustDecodeHex("6f776e6572"),
			DBID:  "xabc",
		},
		{
			Name:  "db_b",
			Owner: mustDecodeHex("6f776e6572"),
			DBID:  "xdef",
		},
	},
		owner: mustDecodeHex("6f776e6572")},
	nil, "text")
Output:

Databases belonging to '6f776e6572':
  DBID: xabc
    Name: db_a
    Owner: 6f776e6572
  DBID: xdef
    Name: db_b
    Owner: 6f776e6572
Example (RespDBlist_text_0)
display.Print(
	&respDBList{Info: []*types.DatasetIdentifier{}, owner: mustDecodeHex("6f776e6572")},
	nil, "text")
Output:

No databases found for '6f776e6572'.
Example (RespRelations_json)
display.Print(&respRelations{
	Data: clientType.NewRecordsFromMaps([]map[string]any{{"a": "1", "b": "2"}, {"a": "3", "b": "4"}})},
	nil, "json")
Output:

{
  "result": [
    {
      "a": "1",
      "b": "2"
    },
    {
      "a": "3",
      "b": "4"
    }
  ],
  "error": ""
}
Example (RespRelations_text)
display.Print(&respRelations{
	Data: clientType.NewRecordsFromMaps([]map[string]any{{"a": "1", "b": "2"}, {"a": "3", "b": "4"}})},
	nil, "text")
Output:

| a | b |
+---+---+
| 1 | 2 |
| 3 | 4 |
Example (RespSchema_json)
display.Print(demoSchema, nil, "json")
Output:

{
  "result": {
    "owner": "dXNlcg==",
    "name": "test_schema",
    "tables": [
      {
        "name": "users",
        "columns": [
          {
            "name": "id",
            "type": "integer",
            "attributes": [
              {
                "type": "primary_key",
                "value": "true"
              }
            ]
          }
        ],
        "indexes": [
          {
            "name": "index_name",
            "columns": [
              "id",
              "name"
            ],
            "type": "btree"
          }
        ],
        "foreign_keys": [
          {
            "child_keys": [
              "child_id"
            ],
            "parent_keys": [
              "parent_id"
            ],
            "parent_table": "parent_table",
            "actions": [
              {
                "on": "delete",
                "do": "cascade"
              }
            ]
          }
        ]
      }
    ],
    "actions": [
      {
        "name": "get_user",
        "inputs": [
          "user_id"
        ],
        "mutability": "update",
        "auxiliaries": [
          "mustsign"
        ],
        "public": true,
        "statements": [
          "SELECT * FROM users WHERE id = $user_id"
        ]
      }
    ],
    "extensions": [
      {
        "name": "auth",
        "config": [
          {
            "argument": "token",
            "value": "abc123"
          }
        ],
        "alias": "authentication"
      }
    ]
  },
  "error": ""
}
Example (RespSchema_text)
display.Print(demoSchema, nil, "text")
Output:

Tables:
  users
    Columns:
    id
      Type: integer
      primary_key
        true
Actions:
  get_user (public)
    Inputs: [user_id]

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInputs added in v0.6.5

func GetInputs(args []string, action *transactions.Action) ([][]any, error)

func NewCmdDatabase

func NewCmdDatabase() *cobra.Command

func UnmarshalJson

func UnmarshalJson(file *os.File) (*transactions.Schema, error)

func UnmarshalKf

func UnmarshalKf(file *os.File) (*transactions.Schema, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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