successfully decoding SiteID finally...

This commit is contained in:
Anish Lakhwara 2024-08-05 23:19:11 -07:00
parent 072e87c05f
commit d178a46605
2 changed files with 5 additions and 5 deletions

View file

@ -59,7 +59,7 @@
Value: Array.isArray(change[3]) ? btoa(String.fromCharCode.apply(null, change[3])) : btoa(change[3]),
ColVersion: Number(change[4]),
DBVersion: Number(change[5]),
SiteID: Array.isArray(change[6]) ? arrayBufferToBase64(Uint8Array.from(change[6]).buffer) : btoa(change[6]),
SiteID: Array.isArray(change[6]) ? btoa(new TextDecoder('utf8').decode(change[6])) : btoa(change[6]),
CL: Number(change[7]),
Seq: Number(change[8])
}));

View file

@ -80,7 +80,7 @@ type CRSQLChange struct {
Value []byte
ColVersion int64
DBVersion int64
SiteID []byte
SiteID []int
CL int64
Seq int64
}
@ -108,8 +108,8 @@ func mapToCRSQLChange(m map[string]interface{}) (CRSQLChange, error) {
if err != nil {
return change, err
}
//change.SiteID, err = decodeBase64ToIntArray(m["SiteID"].(string))
change.SiteID, err = base64.URLEncoding.DecodeString(m["SiteID"].(string))
change.SiteID, err = decodeBase64ToIntArray(string(m["SiteID"].(string)))
fmt.Println(change.SiteID)
if err != nil {
return change, err
}
@ -162,7 +162,7 @@ func applyChanges(changes []interface{}) {
log.Println("Error inserting change:", err)
}
log.Println("We inserted data successfully??")
printChange(change)
fmt.Println(c)
} else {
fmt.Println("Not OK to convert change")
fmt.Println("Change look like:")