MCPcopy
hub / github.com/pocketbase/pocketbase / JSONEach

Function JSONEach

tools/dbutils/json.go:10–17  ·  view source on GitHub ↗

JSONEach returns JSON_EACH SQLite string expression with some normalizations for non-json columns.

(column string)

Source from the content-addressed store, hash-verified

8// JSONEach returns JSON_EACH SQLite string expression with
9// some normalizations for non-json columns.
10func JSONEach(column string) string {
11 // note: we are not using the new and shorter "if(x,y)" syntax for
12 // compatibility with custom drivers that use older SQLite version
13 return fmt.Sprintf(
14 `json_each(CASE WHEN iif(json_valid([[%s]]), json_type([[%s]])='array', FALSE) THEN [[%s]] ELSE json_array([[%s]]) END)`,
15 column, column, column, column,
16 )
17}
18
19// JSONArrayLength returns JSON_ARRAY_LENGTH SQLite string expression
20// with some normalizations for non-json columns.

Callers 6

TestJSONEachFunction · 0.92
expandRecordsMethod · 0.92
processActivePropsMethod · 0.92
cascadeRecordDeleteFunction · 0.92
FindRecordByViewFileMethod · 0.92

Calls

no outgoing calls

Tested by 1

TestJSONEachFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…