private IEnumerator Start () { Debug.LogFormat ("Data path = {0}", Application.persistentDataPath); #if UNITY_EDITOR_WIN Log.SetLogger(new UnityLogger()); #endif _db = Manager.SharedInstance.GetDatabase ("spaceshooter"); _pull = _db.CreatePullReplication (GameController.SYNC_URL); _pull.Continuous = true; _pull.Start (); while (_pull != null && _pull.Status == ReplicationStatus.Active) { yield return new WaitForSeconds(0.5f); } var doc = _db.GetExistingDocument ("player_data"); if (doc != null) { //We have a record! Get the ship data, if possible. string assetName = String.Empty; if(doc.UserProperties.ContainsKey("ship_data")) { assetName = doc.UserProperties ["ship_data"] as String; } StartCoroutine(LoadAsset (assetName)); } else { //Create a new record doc = _db.GetDocument("player_data"); doc.PutProperties(new Dictionary<string, object> { { "ship_data", String.Empty } }); } doc.Change += DocumentChanged; _push = _db.CreatePushReplication (new Uri ("http://127.0.0.1:4984/spaceshooter")); _push.Start(); }
private void VerifyDocs(Database db, bool withAttachments) { for (int i = 1; i <= DOCUMENT_COUNT; i++) { var doc = db.GetExistingDocument(String.Format("doc-{0}", i)); Assert.IsNotNull(doc); Assert.AreEqual(i, doc.UserProperties["index"]); Assert.AreEqual(false, doc.UserProperties["bar"]); if (withAttachments) { Assert.IsNotNull(doc.CurrentRevision.GetAttachment("README")); } } Assert.AreEqual(DOCUMENT_COUNT, db.GetDocumentCount()); }
private void VerifyDocs(Database db, bool withAttachments) { for (int i = 1; i <= DOCUMENT_COUNT; i++) { var doc = db.GetExistingDocument(String.Format("doc-{0}", i)); Assert.IsNotNull(doc); Assert.AreEqual(i, doc.UserProperties["index"]); Assert.AreEqual(false, doc.UserProperties["bar"]); if (withAttachments) { Assert.IsNotNull(doc.CurrentRevision.GetAttachment("README")); } } Assert.AreEqual(DOCUMENT_COUNT, db.DocumentCount); }
public void DeleteItem(string ItemId) { var doc = db.GetExistingDocument(ItemId); doc.Delete(); }
public static object LoadObject(Type objType, Guid id, Database db, IDReferenceResolver resolver = null) { Document doc = db.GetExistingDocument (id.ToString ()); return DeserializeObject (objType, doc, db, resolver); }