Categorygithub.com/brane-app/database-library
modulepackage
0.0.0-20211123022145-226b2b1fbf05
Repository: https://github.com/brane-app/database-library.git
Documentation: pkg.go.dev

# Functions

* * Check that password `password` matches the hash for user of id `ID` * Done in one query: * read hash: SELECT hash FROM AUTH_TABLE WHERE id=ID LIMIT 1 */.
* * Check that a secret `secret` for some user of id `ID` matches * Done in one query: * read secret: SELECT secret FROM SECRET_TABLE WHERE id=ID LIMIT 1 */.
* * Connect to a database, given a connection string * If the connection fails a ping, this function wil panic with the err * The conenction string should look something like * user:pass@tcp(addr)/table */.
No description provided by the author
* * Create a secret for some user of id `ID` * Any existing secret for that user is destroyed * Done in one query: * update secret REPLACE INTO SECRET_TABLE (id, secret) VALUES ID, new_secret */.
* * Create a token for some user of id `ID` that expires in 24 hours * Any existing token for that user is destroyed * Done in one query: * update secret REPLACE INTO TOKEN_TABLE (id, token, created) VALUES ID, new_token, now */.
* * Delete some content of id `ID` * Uses 1 querie * delete content: DELETE FROM CONTENT_TABLE WHERE id=ID LIMIT 1 */.
* * Delete some user from USER_TABLE * Uses 1 query: * delete user: DELETE FROM USER_TABLE WHERE id=ID LIMIT 1 */.
No description provided by the author
* * Ping the database, and return any error * useful for health checks */.
* * Increment the post count of user of id `ID` by one * Done in one query * increment: UPDATE USER_TABLE SET post_count=post_count+1 WHERE id=ID */.
No description provided by the author
* * Get whether or not a user is banned, either by a permanent ban, or an expirable ban * Done in one query */.
No description provided by the author
* * Same as ReadManyContent but for some author of id `ID` * Uses 2 queries * get content: SELECT * FROM CONTENT_TABLE ORDER BY created DESC LIMIT offset, count * queries from: getManyTags */.
* * Read a slice of bans of a user * Done in one query */.
* * Read `count` number of contents, before content of id `before` * If the first set of content should be read, `before` may be empty * Newest posts are returned first * Uses 2 queries * get content: SELECT * FROM CONTENT_TABLE ORDER BY created DESC LIMIT offset, count * queries from: getManyTags */.
* * Read a slice of unresolved reports (ie, the mod queue) by order of most recent * Done in one query */.
* * Read a single ban of id `ID` * Done in one query */.
* * Read some content of id `ID` * Uses 2 queries * get content: SELECT * FROM CONTENT_TABLE WHERE id=ID LIMIT 1 * get tags: SELECT tag FROM TAG_TABLE WHERE id=ID */.
* * Lookup single report by it's ID * Done in one query */.
* * Read some user of id `ID` from USER_TABLE * Uses 1 query * read user: SELECT * FROM USER_TABLE WHERE id=ID LIMIT 1 */.
* * Read some user of email `email` from USER_TABLE * Works in the same way as ReadSingleUser, but with email * Uses 1 query * read user: SELECT * FROM USER_TABLE WHERE email=email LIMIT 1 */.
* * Read some user of email `email` from USER_TABLE * Works in the same way as ReadSingleUser, but with nick * Uses 1 query * read user: SELECT * FROM USER_TABLE WHERE nick=nick LIMIT 1 */.
* * Read information about some token `token` * Returns who it belongs to, and whether or not it's valid * done in one query: * read token: SELECT id, created FROM TOKEN_TABLE WHERE token=? LIMIT 1 */.
* * Revoke the secret of some user of id `ID` * Done in one query: * delete row: DELETE FROM SECRET_TABLE WHERE id=ID LIMIT 1 */.
* * Revoke some token `token` * Done in one query: * delete row: DELETE FROM TOKEN_TABLE WHERE token=token LIMIT 1 */.
* * Revoke the token of some user of id `ID` * Done in one query: * delete row: DELETE FROM TOKEN_TABLE WHERE id=ID LIMIT 1 */.
No description provided by the author
No description provided by the author
* * Set a password `password` for some user of id `ID` * Done in one query: * write row: REPLACE INTO AUTH_TABLE (id, hash) VALUES (ID, hash(password)) */.
No description provided by the author
* * Write some content `content` to the table CONTENT_TABLE * Uses 3 query * write content: REPLACE INTO CONTENT_TABLE (keys...) VALUES (values...) * queries from: setTags * Returns error, if any */.
* * Create or update a report for some user * Done in one query */.
* * Write some user `user` into USER_TABLE * Uses 1 query * write user: REPLACE INTO USER_TABLE (keys...) VALUES (values...) * Returns error, if any */.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
INCREMENT_USER_POST_COUNT_OF_ID
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author