Hi guys!
Trying to get the hang of this, and ran into a question here at the start.
- I have CBServer 6.5 set up in the cloud
- I have CBGateway in the cloud
- I’m making a Xamarin.Forms app (dot-net c#). This class works fine. (abbreviated to show the pertinent areas)
============================================================
class DB : IDisposable
{
Database _database;
Replicator _replicator;
public DB()
{
var defaultDirectory = Service.GetInstance<IDefaultDirectoryResolver>().DefaultDirectory() ;
var databaseConfig = new DatabaseConfiguration { Directory = defaultDirectory } ;
_database = new Database("profile", databaseConfig) ;
Uri _remoteSyncUrl = new Uri("ws://xxx.xxx.xxx.xxx:4984");
var targetUrlEndpoint = new URLEndpoint(new Uri(_remoteSyncUrl, "profile"));
var configuration = new ReplicatorConfiguration(_database, targetUrlEndpoint)
{
ReplicatorType = ReplicatorType.PushAndPull,
Continuous = true
};
_replicator = new Replicator(configuration);
_replicator.Start();
}
public string MakeTestDoc()
{
using (var mutableDoc = new MutableDocument("test1"))
{
mutableDoc.SetString("foo", "bar");
_database.Save(mutableDoc);
return mutableDoc.Id;
}
}
public string GetTestDoc(string TestID)
{
var doc = _database.GetDocument(TestID);
if (doc == null)
return "null" ;
return doc.GetString("foo");
}
}
============================================================
And here’s how I’m using it:
============================================================
DB a = new DB() ;
a.MakeTestDoc();
Console.WriteLine(a.GetTestDoc("test1")) ;
============================================================
GetTestDoc() returns “bar” like it should. And when I go to CBServer Administration and look in the bucket, the document is there, and looks exactly like we would expect it to look.
Here’s where my question comes up…
Next, I go to the the CBServer Administration, click into my bucket and use the “Add Document” button to create an identical document with “test2” as its Name & DocumentID. And then I run:
============================================================
Console.WriteLine(a.GetTestDoc("test1")) ;
Console.WriteLine(a.GetTestDoc("test2")) ;
============================================================
The first line works fine, same as before. The second line returns “null”.
Why can’t it fetch the document that was created via CBServer Administration?
Here’s the metadata for the 2 documents, they’re quite similar. No channels.
{
"meta": {
"id": "test1,
"rev": "1-161e085e3e2f00000000000000000000",
"expiration": 0,
"flags": 0,
"type": "json"
},
"xattrs": {
"_sync": {
"rev": "1-9080e71ec785faccac6152e6cb5611cc7748de82",
"sequence": 74,
"recent_sequences": [
74
],
"history": {
"revs": [
"1-9080e71ec785faccac6152e6cb5611cc7748de82"
],
"parents": [
-1
],
"channels": [
null
]
},
"cas": "0x00002f3e5e081e16",
"value_crc32c": "0x5451e331",
"time_saved": "2020-07-02T20:08:37.146443258Z"
}
}
}
{
"meta": {
"id": "test2",
"rev": "2-161e0a6449cf00000000000002000006",
"expiration": 0,
"flags": 33554438,
"type": "json"
},
"xattrs": {
"_sync": {
"rev": "1-a9be417c554029c89a25d15f79877101",
"sequence": 77,
"recent_sequences": [
77
],
"history": {
"revs": [
"1-a9be417c554029c89a25d15f79877101"
],
"parents": [
-1
],
"channels": [
null
]
},
"cas": "0x0000cf49640a1e16",
"value_crc32c": "0xf1dd538a",
"time_saved": "2020-07-02T20:45:42.122088852Z"
}
}
}
Thanks for looking at this. Have a great day!
Kind regards,
David