Dzoukr / CosmoStore

F# Event store for Azure Cosmos DB, Table Storage, Postgres, LiteDB & ServiceStack
MIT License
168 stars 21 forks source link

Azure Table Storage requires JToken payload #50

Closed bzuu-ic closed 3 years ago

bzuu-ic commented 3 years ago

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'
bzuu-ic commented 3 years ago

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