Hi,
I have this issue where i am trying to update a document. The first time i attempt to update the document everything goes flawless. However, after i want to make a 2nd update the value remains the same after saving to the database.
here is my code:
public void CreateSingleDocumentFromDictionary(IDictionary<string, object> info, bool update = false)
{
using (var database = new Database(DbName))
{
object value;
if (info.TryGetValue("key", out value))
{
if (database.GetDocument(value.ToString()) == null || update == true)
{
var document = new MutableDocument(value.ToString(), info);
database.Save(document);
if (database.GetDocument(value.ToString()) != null)
{
Task.Run(() => Logger.Info(String.Format("DOCUMENT Created: id {0}", value.ToString())));
}
var tst = database.GetDocument(document.Id);
var psd = tst.GetObject("purchasedetails");
}
else
{
Logger.Error(null, "id already in database", (object)JsonConvert.SerializeObject(info));
throw new NoKeyPropertyException(String.Format("Id already in db in object(s) during
document creation"));
}
}
else
{
Logger.Error(null, "No key found in object(s)", (object)JsonConvert.SerializeObject(info));
throw new NoKeyPropertyException(String.Format("No key found in object(s) during document
creation"));
}
}
}
where if “psd” is a dictionary of a list of objects. The update i made is in an object in that list.
I don’t realy know what im doing wrong here. Im using Couchbase Lite version 2.0.0 db-020.
me and my colleague @thomas1983 have been breaking our heads on this for the entire afternoon.
I checked the documentation about this and it says that sometimes changes might not get through due to multiple instances of the database. Here, I check the results of my “update” in the same instance.
any suggestions on how this might be caused are welcome.
cheers.