Skip to content

Instantly share code, notes, and snippets.

@RoyalIcing
Created June 2, 2022 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RoyalIcing/c7c1e3f8d7ca47fec2bd00f86378ede0 to your computer and use it in GitHub Desktop.
Save RoyalIcing/c7c1e3f8d7ca47fec2bd00f86378ede0 to your computer and use it in GitHub Desktop.
yieldtable
const Key = primaryKeyText('key');
const Count = column('count', int(1));
const CountersTable = table('counters', [Key, Count]);
function* Create() {
yield create(CounterTable);
}
function* QueryCountFor(key) {
return select([Count], [where(Key(key))]);
}
function* Increment(key) {
return insert(CountersTable, [
Key(key),
onConflict(Key, doUpdateSet(Count(add(1))))
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment