I have a notes applications, where the notes are stored in room database. When I press the sync button for the first time, I want all the notes to be uploaded to firestore cloud, and after the first time, new notes should be uploaded and old ones should be updated (without producing duplicates).
My room entities looks like this
@Entity(tableName = "Notes")
class Notes: Serializable {
@PrimaryKey(autoGenerate = true)
var id:Int? = null
@ColumnInfo(name = "title")
var title:String? = null
@ColumnInfo(name = "lock")
var lock:Boolean? = false
@ColumnInfo(name = "sub_title")
var subTitle:String? = null
@ColumnInfo(name = "date_time")
var dateTime:String? = null
@ColumnInfo(name = "note_text")
var noteText:String? = null
@ColumnInfo(name = "img_path")
var imgPath:String? = null
@ColumnInfo(name = "web_link")
var webLink:String? = null
@ColumnInfo(name = "color")
var color:String? = null
}
I think of using a getAllNotes function, which will return a list of Notes, which I will upload to the cloud. My cloud firestore has a collection with specific user id, where each note is added as a separate document. I'm new to both room database and Firebase, so it'd be great if you could point a way for me to do this.
If I should add any other code, please point it out. Thanks