heyrict / cindy-next-rust

The backend for [cindy-next](https://github.com/heyrict/cindy-next). Written in Rust.

Home Page:https://www.cindythink.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Image uploading

heyrict opened this issue · comments

Description

Images can be a bonus for creating lateral thinking puzzles. Generally users may want to use one or two images in a single puzzle.

Proposed solution

IMO, a table storing paths to pictures and uploaded users, file size, modification time, etc. should be created (one-to-many relationship between user and images may be sufficient in this case), thus alternation in the database is required.
Database alternation is done by files in the migrations folder, created with diesel migration generate. See files there as an example.

The graphql endpoint for uploading files is implemented in async-graphql, documented here.

Alternative solutions

Adding an optional field in puzzle table may allow user to use up to one picture, associated with the puzzle. This could be easier to implement with the cost of flexibility.

I added a column named content_image to puzzle table.
pb10005@6b0c0c3

I added a column named content_image to puzzle table.
pb10005@6b0c0c3

Hey @pb10005 ! Thank you for participating! The code is good to start with :) Going to assign the issue to you if you don't mind.


Edit: you may want to update the schema code diesel print-schema > src/schema.rs