Core API

This page describes the sql functions which make up the bedquilt extension.


bq_generate_id

  • params: None
  • returns: char(24)
  • language: plpgsql

Generate a random string ID. Used by the insert function to populate the '_id' field if missing.

bq_doc_set_key

  • params: i_jdoc json, i_key text, i_val anyelement
  • returns: json
  • language: plpgsql

Set a key in a json document.

bq_collection_exists

  • params: None
  • returns: boolean
  • language: plpgsql

Check if a collection exists. Currently does a simple check for a table with the specified name.

bq_check_id_type

  • params: i_jdoc json
  • returns: VOID
  • language: plpgsql

Ensure the _id field of the supplied json document is a string value. If it's not, an exception is raised. Ideally, the client should validate this is the case before submitting to the server.

bq_create_collection

  • params: i_coll text
  • returns: BOOLEAN
  • language: plpgsql

Create a collection with the specified name

bq_list_collections

  • params: None
  • returns: table(collection_name text)
  • language: plpgsql

Get a list of existing collections. This checks information_schema for tables matching the expected structure.

bq_delete_collection

  • params: i_coll text
  • returns: BOOLEAN
  • language: plpgsql

Delete/drop a collection. At the moment, this just drops whatever table matches the collection name.

bq_find_one

  • params: i_coll text, i_json_query json
  • returns: table(bq_jdoc json)
  • language: plpgsql

find one

bq_find_one_by_id

  • params: i_coll text, i_id text
  • returns: table(bq_jdoc json)
  • language: plpgsql

bq_find

  • params: i_coll text, i_json_query json
  • returns: table(bq_jdoc json)
  • language: plpgsql

find many documents

bq_count

  • params: i_coll text, i_doc json
  • returns: integer
  • language: plpgsql

count documents in collection

bq_insert

  • params: i_coll text, i_jdoc json
  • returns: text
  • language: plpgsql

insert document

bq_remove

  • params: i_coll text, i_jdoc json
  • returns: setof integer
  • language: plpgsql

remove documents

bq_remove_one

  • params: i_coll text, i_jdoc json
  • returns: setof integer
  • language: plpgsql

remove one document

bq_remove_one_by_id

  • params: i_coll text, i_id text
  • returns: setof integer
  • language: plpgsql

remove one document

bq_save

  • params: i_coll text, i_jdoc json
  • returns: text
  • language: plpgsql

save document