Android Question Cloud KVS Server - String data in value instead of BLOB

b4xscripter

Member
Licensed User
Longtime User
First of all, many thanks for the great solution Cloud KVS and I hope, this time this is a right place for this question.
For my projects, it is not the best solution to use the BLOB as data type to store. I would prefer to use String for stored values. As my objects are json, I could easly convert String data into json... Additionaly, I could 'see' this data from any SQLite viewer without making any "conversion script"
Is it possible to implement at the ClientKVS client (B4A) and CloudKVS_Server this String data instead of BLOB?


Thanks in advance!

Best regards
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The simplest way is to modify the last step where the data is written to the server database.
This way you will not need to change the clients code at all.

You need to change
- value column type to TEXT
- Code to insert the data (DB module):
B4X:
Dim ser As B4XSerializator
       sql.ExecNonQuery2("INSERT OR REPLACE INTO data VALUES (?, ?, ?, ?, ?)",  _
           Array (item.UserField, item.KeyField, ser.ConvertBytesToObject(item.ValueField), id, Min(item.TimeField, DateTime.Now)))
- Change this line to get a string from the database and serialize it to bytes with ser.ConvertObjectToBytes
B4X:
item.ValueField = rs.GetBlob("value")
 
Upvote 0

b4xscripter

Member
Licensed User
Longtime User
OK, finally I wanted to replace the BLOB field (value) for the String (TEXT), in local db and server db to have the table with the same structure.
It is working!
So, if anyone has the similar goal (use String Field instead of BLOB), here go my client (B4A) and server (B4J) projects!
Best regards
 

Attachments

  • CloudKVS_Server_STRING_FIELD.zip
    56.4 KB · Views: 175
  • KVS2_STRING_FIELD_CLIENT.zip
    404.8 KB · Views: 164
Upvote 0
Top