Dzoukr / CosmoStore

F# Event store for Azure Cosmos DB, Table Storage, Postgres, LiteDB & ServiceStack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure Table Storage requires JToken payload

bzuu-ic opened this issue · comments

commented

It seems that the Azure Table Store implementation somehow requires a JToken payload. Although if I understand correctly it should allow any type of payload since version 3.

Example script:

#r "nuget: CosmoStore, Version=3.0.1"
#r "nuget: CosmoStore.TableStorage, Version=3.0.1"

open CosmoStore
open System

let storageAccountName = "account"
let storageAuthKey = "key"
let myConfig = TableStorage.Configuration.CreateDefault storageAccountName storageAuthKey
let eventStore = myConfig |> TableStorage.EventStore.getEventStore

let serializedData = """
{
    "value": "data",
    "somenum": 8
}
"""

let eventToWrite = {
    Id = Guid.NewGuid()
    CorrelationId = None
    CausationId = None
    Name = "My custom event"
    Data = serializedData
    Metadata = Some "Super meta"
}
let streamId = "awesome-stream"

eventToWrite |> eventStore.AppendEvent streamId ExpectedVersion.NoStream |> Async.AwaitTask |> Async.RunSynchronously

When you run the script you get the following error:

C:\repos\cosmo\cosmotest.fsx(29,17): error FS0001: Type mismatch. Expecting a
    'EventWrite<string> -> 'a'
but given a
    'EventWrite<Newtonsoft.Json.Linq.JToken> -> Threading.Tasks.Task<EventRead<Newtonsoft.Json.Linq.JToken,int64>>'
The type 'string' does not match the type 'Newtonsoft.Json.Linq.JToken'
commented

Nevermind, I misread the documentation. Apparently this particular database is still tightly coupled to JToken.