deepstreamNet icon indicating copy to clipboard operation
deepstreamNet copied to clipboard

Set an array as a new record

Open grendo opened this issue 7 years ago • 0 comments

Hi, looks like you can not set an array as a record. The DeepStreamRecordBase must be a JContainer. Should it be a JToken so it can support arrays ? Alternatively throw an exception if you try and set an array.

When you try and set an array this line does not merge anything Data.Merge(item, jsonMergeSettings);

Here is a test

        [Test]
        public async Task TestSetArray()
        {
            var name = Guid.NewGuid().ToString();
            var key = @"my/testrecord/" + name;
            var obj = new JArray();
            obj.Add("hello");
            using (var client1 = await GetConnection("chris", "test"))
            {
                var record1 = await client1.Records.GetRecordAsync(key);
                var res = await client1.Records.SetWithAckAsync(record1, obj);
                Assert.IsTrue(res);
                var json = JsonConvert.SerializeObject(record1);
                Assert.IsTrue(json.StartsWith("["), "SHould be an array");
            }
        }

grendo avatar Sep 16 '17 06:09 grendo