-
Notifications
You must be signed in to change notification settings - Fork 912
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugins/sql: listsqlschemas command to retrieve schemas.
Good for detection of what fields are present. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
- Loading branch information
1 parent
a43c515
commit 4318dcb
Showing
8 changed files
with
331 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
lightning-listsqlschemas -- Command to example lightning-sql schemas | ||
==================================================================== | ||
|
||
SYNOPSIS | ||
-------- | ||
|
||
**listsqlschemas** [*table*] | ||
|
||
DESCRIPTION | ||
----------- | ||
|
||
This allows you to examine the schemas at runtime; while they are fully | ||
documented for the current release in lightning-sql(7), as fields are | ||
added or deprecated, you can use this command to determine what fields | ||
are present. | ||
|
||
If *table* is given, only that table is in the resulting list, otherwise | ||
all tables are listed. | ||
|
||
EXAMPLE JSON REQUEST | ||
------------ | ||
```json | ||
{ | ||
"id": 82, | ||
"method": "listsqlschemas", | ||
"params": { | ||
"table": "offers" | ||
} | ||
} | ||
``` | ||
|
||
EXAMPLE JSON RESPONSE | ||
----- | ||
```json | ||
{ | ||
"schemas": [ | ||
{ | ||
"tablename": "offers", | ||
"columns": [ | ||
{ | ||
"name": "offer_id", | ||
"type": "BLOB" | ||
}, | ||
{ | ||
"name": "active", | ||
"type": "INTEGER" | ||
}, | ||
{ | ||
"name": "single_use", | ||
"type": "INTEGER" | ||
}, | ||
{ | ||
"name": "bolt12", | ||
"type": "TEXT" | ||
}, | ||
{ | ||
"name": "bolt12_unsigned", | ||
"type": "TEXT" | ||
}, | ||
{ | ||
"name": "used", | ||
"type": "INTEGER" | ||
}, | ||
{ | ||
"name": "label", | ||
"type": "TEXT" | ||
} | ||
], | ||
"indices": [ | ||
[ | ||
"offer_id" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
RETURN VALUE | ||
------------ | ||
|
||
[comment]: # (GENERATE-FROM-SCHEMA-START) | ||
On success, an object containing **schemas** is returned. It is an array of objects, where each object contains: | ||
|
||
- **tablename** (string): the name of the table | ||
- **columns** (array of objects): the columns, in database order: | ||
- **name** (string): the name the column | ||
- **type** (string): the SQL type of the column (one of "INTEGER", "BLOB", "TEXT", "REAL") | ||
- **indices** (array of arrays, optional): Any index we created to speed lookups: | ||
- The columns for this index: | ||
- The column name | ||
|
||
[comment]: # (GENERATE-FROM-SCHEMA-END) | ||
|
||
AUTHOR | ||
------ | ||
|
||
Rusty Russell <<rusty@rustcorp.com.au>> is mainly responsible. | ||
|
||
SEE ALSO | ||
-------- | ||
|
||
lightning-sql(7). | ||
|
||
RESOURCES | ||
--------- | ||
|
||
Main web site: <https://github.com/ElementsProject/lightning> | ||
[comment]: # ( SHA256STAMP:4ce219bf63d1ce5f9e3337c767f3258bb758b5ab474fe2792df4daa78165aded) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"required": [], | ||
"properties": { | ||
"table": { | ||
"type": "string" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"required": [ | ||
"schemas" | ||
], | ||
"properties": { | ||
"schemas": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"required": [ | ||
"tablename", | ||
"columns" | ||
], | ||
"properties": { | ||
"tablename": { | ||
"type": "string", | ||
"description": "the name of the table" | ||
}, | ||
"columns": { | ||
"type": "array", | ||
"description": "the columns, in database order", | ||
"items": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"required": [ | ||
"name", | ||
"type" | ||
], | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"description": "the name the column" | ||
}, | ||
"type": { | ||
"type": "string", | ||
"enum": [ | ||
"INTEGER", | ||
"BLOB", | ||
"TEXT", | ||
"REAL" | ||
], | ||
"description": "the SQL type of the column" | ||
} | ||
} | ||
} | ||
}, | ||
"indices": { | ||
"type": "array", | ||
"description": "Any index we created to speed lookups", | ||
"items": { | ||
"type": "array", | ||
"description": "The columns for this index", | ||
"items": { | ||
"type": "string", | ||
"description": "The column name" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters