Hi Fam
A couple of questions using MiniORMS with handlers.
This is based on this tutorial
www.b4x.com
In this code
Q1. If for example my handler expects /records/users but a user enters /records how do I return an error message as the expected content does not meet the criteria?
Q2. For all METHOD calls, I'd like to (a) detect if there are some parameters provided. For example, on the GET call, I'd like to filter the records in my table based on the provided parameters. These could be to filter the records to return, sort them and perhaps limit the number of records returned?
Q3. For a DELETE call, if I pass parameters, how to I also detect that a parameter was specified and if its available I execute DELETE WHERE ? based on those parameters.
Q4. For a POST and a PUT, the record added/updated, how do I return the "id" field ONLY as JSON if the INSERT/UPDATE call was successful, and or when needed return the complete record including the new autoincrement id used.
Q5. In case of using own ID i.e. not autoincrement, these will be strings, how do I indicate the "id" type and also make the MiniORM use the specified id i provided?
A couple of questions using MiniORMS with handlers.
This is based on this tutorial
Using MiniORMUtils in Web API Server v3
Introduction At the time of writing, MiniORMUtils is version 1.14 and Web API Server v3 is version 3.00. MiniORMUtils support SQLite and MySQL databases. We don't need to write different SQL queries to work with SQLite and later migrate to MySQL. How to Use MiniORMUtils When we run Web API...

In this code
B4X:
Sub Handle (req As ServletRequest, resp As ServletResponse)
Request = req
Response = resp
Method = Request.Method.ToUpperCase
Dim FullElements() As String = WebApiUtils.GetUriElements(Request.RequestURI)
Elements = WebApiUtils.CropElements(FullElements, 3) ' 3 For Api handler
Select Method
Case "GET"
...
Case "POST"
...
Case "PUT"
...
Case "DELETE"
...
Case Else
Log("Unsupported method: " & Method)
ReturnMethodNotAllow
Return
End Select
ReturnBadRequest
End Sub
Q1. If for example my handler expects /records/users but a user enters /records how do I return an error message as the expected content does not meet the criteria?
Q2. For all METHOD calls, I'd like to (a) detect if there are some parameters provided. For example, on the GET call, I'd like to filter the records in my table based on the provided parameters. These could be to filter the records to return, sort them and perhaps limit the number of records returned?
Q3. For a DELETE call, if I pass parameters, how to I also detect that a parameter was specified and if its available I execute DELETE WHERE ? based on those parameters.
Q4. For a POST and a PUT, the record added/updated, how do I return the "id" field ONLY as JSON if the INSERT/UPDATE call was successful, and or when needed return the complete record including the new autoincrement id used.
Q5. In case of using own ID i.e. not autoincrement, these will be strings, how do I indicate the "id" type and also make the MiniORM use the specified id i provided?