This is a similar solution to RDC that works with MongoDB databases.
MongoDB is a simple and powerful NoSQL database. It is a bit like KVS (key value store) class. However unlike KVS which is a simple data store, MongoDB is a full database with powerful analytics features.
The B4J server acts as a middleware between the clients and the database.
B4J MongoDB library: https://www.b4x.com/android/forum/threads/mongodb-documents-database.72160/
There is nothing to configure in the server side except of the server port. The server code is simple and
can be extended as needed.
Unlike RDC where the queries are set in the server side, in RMDBC the commands are set in the clients. This means that this solution as-is is more appropriate for trusted environments. You can add validation code to the server to make it more secure.
Client code
1. Add the types declaration to the main module:
2. Add MDBRequestManager class to your project. It depends on OkHttpUtils2 and RandomAccessFile library.
Note that it is compatible with B4A, B4i and B4J.
3. Initialize the manager:
4. Handle the events:
See the attached B4A and B4i client examples:
MongoDB is a simple and powerful NoSQL database. It is a bit like KVS (key value store) class. However unlike KVS which is a simple data store, MongoDB is a full database with powerful analytics features.
The B4J server acts as a middleware between the clients and the database.
B4J MongoDB library: https://www.b4x.com/android/forum/threads/mongodb-documents-database.72160/
There is nothing to configure in the server side except of the server port. The server code is simple and
can be extended as needed.
Unlike RDC where the queries are set in the server side, in RMDBC the commands are set in the clients. This means that this solution as-is is more appropriate for trusted environments. You can add validation code to the server to make it more secure.
Client code
1. Add the types declaration to the main module:
B4X:
Type MDBCommand (Collection As String, Maps As List, Method As String, Limit As Int)
Type MDBResult (Success As Boolean, Tag As Object)
2. Add MDBRequestManager class to your project. It depends on OkHttpUtils2 and RandomAccessFile library.
Note that it is compatible with B4A, B4i and B4J.
3. Initialize the manager:
B4X:
manager.Initialize(Me, "mdb", "http://192.168.0.6:51042/rmdbc") 'RMDBC server ip and port
4. Handle the events:
B4X:
Sub JobDone (j As HttpJob)
If manager.HandleJob(j) Then Return
'handle other HttpJobs here
End Sub
Public Sub MDB_NonFindResult (Result As MDBResult)
Log("Command completed. Success =" & Result.Success)
If Result.Success Then GetResults
End Sub
Public Sub MDB_FindResult (Result As MDBResult, Documents As List)
If Result.Success Then
ListView1.Clear
For Each m As Map In Documents
ListView1.AddSingleLine(m.Get("_id") & ": " & m.Get("total"))
Next
End If
End Sub
See the attached B4A and B4i client examples: