Skip to content

Instantly share code, notes, and snippets.

@Altreus
Created July 22, 2020 13:05
Show Gist options
  • Save Altreus/b99550c403ae1803c6afbaf679d847f6 to your computer and use it in GitHub Desktop.
Save Altreus/b99550c403ae1803c6afbaf679d847f6 to your computer and use it in GitHub Desktop.
$ raku -e '
use Red:api<2>;
model Reputation is table<reputation> is rw is export {
has Int $.guild-id is id;
has Int $.user-id is id;
has Int $.reputation is column;
has DateTime $.last-updated is column = DateTime.now;
}
red-defaults "SQLite";
Reputation.^create-table;
my $*RED-DEBUG = True;
.elems ?? .map(*.reputation += 1).save !! .create: :1reputation with Reputation.^all.grep({ .guild-id == 1 && .user-id == 2 });
.elems ?? .map(*.reputation += 1).save !! .create: :1reputation with Reputation.^all.grep({ .guild-id == 1 && .user-id == 2 });
'
SQL : SELECT
count('*') as "data_1"
FROM
reputation
WHERE
reputation.guild_id = 1 AND reputation.user_id = 2
LIMIT 1
BIND: []
SQL : INSERT INTO reputation(
last_updated,
guild_id,
reputation,
user_id
)
VALUES(
?,
?,
?,
?
)
BIND: ["2020-07-22T14:03:00.400751+01:00", 1, 1, 2]
SQL : SELECT
reputation.guild_id as "guild-id", reputation.user_id as "user-id", reputation.reputation , reputation.last_updated as "last-updated"
FROM
reputation
WHERE
_rowid_ = last_insert_rowid()
LIMIT 1
BIND: []
SQL : SELECT
reputation.guild_id as "guild-id", reputation.user_id as "user-id", reputation.reputation , reputation.last_updated as "last-updated"
FROM
reputation
WHERE
reputation.guild_id = 1 AND reputation.user_id = 2
LIMIT 1
BIND: []
SQL : SELECT
count('*') as "data_1"
FROM
reputation
WHERE
reputation.guild_id = 1 AND reputation.user_id = 2
LIMIT 1
BIND: []
Dynamic variable $*RED-FALLBACK not found
in block at /home/adouglas/src/rakudo-2020.01/share/perl6/site/sources/18BD1270AD3DC3798821C80F50B2F56AABCF9C0E (Red::ResultSeq) line 226
in method map at /home/adouglas/src/rakudo-2020.01/share/perl6/site/sources/18BD1270AD3DC3798821C80F50B2F56AABCF9C0E (Red::ResultSeq) line 224
in block <unit> at -e line 21
Actually thrown at:
in block at /home/adouglas/src/rakudo-2020.01/share/perl6/site/sources/18BD1270AD3DC3798821C80F50B2F56AABCF9C0E (Red::ResultSeq) line 226
in block at /home/adouglas/src/rakudo-2020.01/share/perl6/site/sources/18BD1270AD3DC3798821C80F50B2F56AABCF9C0E (Red::ResultSeq) line 226
in method map at /home/adouglas/src/rakudo-2020.01/share/perl6/site/sources/18BD1270AD3DC3798821C80F50B2F56AABCF9C0E (Red::ResultSeq) line 224
in block <unit> at -e line 21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment