Created
June 2, 2022 10:59
-
-
Save RoyalIcing/c7c1e3f8d7ca47fec2bd00f86378ede0 to your computer and use it in GitHub Desktop.
yieldtable
This file contains hidden or 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
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