fixed sql execute

This commit is contained in:
Ren Amamiya
2023-03-17 14:15:10 +07:00
parent 1084b208d3
commit e9aa7bd4ff
6 changed files with 15 additions and 34 deletions

View File

@@ -17,13 +17,10 @@ export const UserExtend = memo(function UserExtend({ pubkey, time }: { pubkey: s
const insertCacheProfile = useCallback(
async (event) => {
const metadata: any = JSON.parse(event.content);
// insert to database
await db.execute(
`INSERT OR IGNORE INTO cache_profiles (id, metadata) VALUES ("${pubkey}", '${JSON.stringify(metadata)}')`
);
await db.execute('INSERT OR IGNORE INTO cache_profiles (id, metadata) VALUES (?, ?);', [pubkey, event.content]);
// update state
setProfile(metadata);
setProfile(JSON.parse(event.content));
},
[db, pubkey]
);