Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
docs(desktop): add query docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaBrighi committed May 15, 2023
1 parent ca77670 commit d3af591
Showing 1 changed file with 71 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,43 +58,108 @@ internal interface DesktopDAO {
@Insert(onConflict = OnConflictStrategy.ABORT)
fun addSchoolSupply(schoolSupply: SchoolSupply)

/**
* Add a wrote relation to the database
*
* @param wrote the wrote relation to add
*/
@Insert(onConflict = OnConflictStrategy.IGNORE)
fun addWrote(wrote: Wrote)

/**
* Change the field in_backpack of a school supply to true
*
* @param rfid the rfid of the school supplies to put in the backpack
*/
@Query("UPDATE school_supplies SET in_backpack = 1 WHERE rfid IN (:rfid)")
fun putSchoolSuppliesInBackpack(rfid: Set<String>)

/**
* Change the field in_backpack of a school supply to false
*
* @param rfid the rfid of the school supplies to take from the backpack
*/
@Query("UPDATE school_supplies SET in_backpack = 0 WHERE rfid IN (:rfid)")
fun takeSchoolSuppliesFromBackpack(rfid: Set<String>)

/**
* Get all the authors
*
* @return the authors
*/
@Query("SELECT * FROM Authors WHERE name = :name")
fun getAuthors(name: String): List<Author>

/**
* Get an author from its id
*
* @param authorId the author id
* @return the author
*/
@Query("SELECT * FROM Authors WHERE author_id = :authorId")
fun getAuthor(authorId: Long): Author

/**
* Get all school supply types
*
* @return the school supply types
*/
@Query("SELECT * FROM School_supply_types")
fun getSchoolSupplyTypes(): List<SchoolSupplyType>

/**
* Get a school supply type from its name
*
* @param type the school supply type name
* @return the school supply type
*/
@Query("SELECT * FROM School_supply_types WHERE type = :type")
fun getSchoolSupplyTypesFromName(type: String): List<SchoolSupplyType>

/**
* Get all books
*
* @return the books
*/
@Transaction
@Query("SELECT * FROM Books")
fun getBooks(): List<BookWithAuthors>

/**
* Get a book from its isbn
*
* @param isbn the book isbn
* @return the book
*/
@Transaction
@Query("SELECT * FROM Books WHERE isbn = :isbn")
fun getBook(isbn: String): BookWithAuthors?

/**
* Get all book copy from the rfid
*
* @param rfid the book copy rfid
* @return the book copy
*/
@Transaction
@Query("SELECT * FROM Book_copies WHERE rfid = :rfid")
fun getBookCopy(rfid: String): List<BookCopyWithAuthors>
fun getBookCopy(rfid: String): BookCopyWithAuthors?

/**
* Get all book copies in the backpack
*
* @return the book copies in the backpack
*/
@Transaction
@Query("SELECT * FROM Book_copies WHERE in_backpack = 1")
fun getBookCopiesInBackpack(): List<BookCopyWithAuthors>

/**
* Get the school supply type from the rfid
*
* @param rfid the school supply
* @return the school supply type
*/
@Transaction
@Query(
"SELECT School_supply_types.type" +
Expand All @@ -103,6 +168,11 @@ internal interface DesktopDAO {
)
fun getSchoolSupplyType(rfid: String): String?

/**
* Get all school supplies' rfid
*
* @return the school supplies' rfid
*/
@Transaction
@Query("SELECT rfid FROM School_supplies")
fun getAllSchoolSupplyRfid(): List<String>
Expand Down

0 comments on commit d3af591

Please sign in to comment.