Conversation
|
📖 Documentation Preview: https://plash-docs-pr-77.pla.sh |
| from plash_cli.auth import send_magiclink | ||
|
|
||
| db = database('data/data.db') | ||
| users = db.t.user.create(id=int, email=str, pk='id', if_not_exists=True) |
There was a problem hiding this comment.
I don't think you need if_not_exists? Also do you need to import database from fastlite?
There was a problem hiding this comment.
We do need it because otherwise on a second start when the database already exists it raises SQLError: table [user] already exists. I double checked the fasthtml docs and did find there's a different suggested pattern so I've moved to use that instead:
class User: id:int; email:str
class Passkey: id:str; user_id:int; public_key:bytes; sign_count:int
users = db.create(User)
passkeys = db.create(Passkey)Re database: it's also exported from fasthtml.common so we technically dont need to include it in the imports. do you prefer we'd add it?
There was a problem hiding this comment.
heres the docs I referred to: https://www.fastht.ml/docs/ref/best_practice.html#database-table-creation
| db = database('data/data.db') | ||
| users = db.t.user.create(id=int, email=str, pk='id', if_not_exists=True) | ||
| passkeys = db.t.passkey.create(id=str, user_id=int, public_key=bytes, sign_count=int, pk='id', if_not_exists=True) | ||
| User,Passkey = users.dataclass(),passkeys.dataclass() |
There was a problem hiding this comment.
I think the approach here is neater for fastlite stuff: https://github.com/AnswerDotAI/fasthtml/blob/main/examples/adv_app_strip.py
There was a problem hiding this comment.
Woops, missed this comment, but I got to the same solution in the other thread. Thanks!
This PR adds a helper for magic links and an example for the fasthtml magickey implementation.