You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi again,
Sorry for the list of issues I'm publishing, but I do it for the benefit of the code and to be clearer readability.
I think that the code that uses the library must know a lot about it.
First: The code must know about the name of the values.
When I want to delete a record by its identifier, expressing it clearly.
The code computers.Delete(Query.LT("Id", BsonValue(myPc.Id-3)))
does not work. In the register, Id is a value, but as a programmer I have to know that it is stored as _id, in order to use it, and so computers.Delete(Query.LT("_id", BsonValue(myPc.Id-3))) works correctly.
I don't know if it's so by design, or it's a simple mistake that can be easily fixed.
Second: The code must know the underlying Bson format.
For each Query/Find I must indicate previously a conversion to Bson, as in the previous example, or the simple computers.FindById(BsonValue(1)) or computers.Find(Query.EQ("Manufacturer", BsonValue("System77"))) |> Seq.iter (printfn "%A"). It's harder to read.
In the C# version it seems to me that the conversion is done internally.
var results = col.Find(Query.StartsWith("Name", "Jo"));
var results = col.Find(Query.GT("Products[*].Price", 100))
I think doing it inside the wrapper would help to clarify the code and it would be more F# idiomatic. It's a simple modification, but it's structural. Maybe for the next version 3.
Tell me what you think.
And thank you again
The text was updated successfully, but these errors were encountered:
Hello @srlopez, you seem to have found the problem that this library solves for F# ;) The description says: "... with type-safe query expression through F# quotations" which is how you should query your data without needing to know about BsonDocuments.
In the README there are many examples of querying the data using quotations but you have to open the namespace LiteDB.FSharp.Extensions and your LiteCollection will have extensions methods:
Hi again,
Sorry for the list of issues I'm publishing, but I do it for the benefit of the code and to be clearer readability.
I think that the code that uses the library must know a lot about it.
First: The code must know about the name of the values.
When I want to delete a record by its identifier, expressing it clearly.
The code
computers.Delete(Query.LT("Id", BsonValue(myPc.Id-3)))
does not work. In the register, Id is a value, but as a programmer I have to know that it is stored as _id, in order to use it, and so
computers.Delete(Query.LT("_id", BsonValue(myPc.Id-3)))
works correctly.I don't know if it's so by design, or it's a simple mistake that can be easily fixed.
Second: The code must know the underlying Bson format.
For each Query/Find I must indicate previously a conversion to Bson, as in the previous example, or the simple
computers.FindById(BsonValue(1))
orcomputers.Find(Query.EQ("Manufacturer", BsonValue("System77"))) |> Seq.iter (printfn "%A")
. It's harder to read.In the C# version it seems to me that the conversion is done internally.
I think doing it inside the wrapper would help to clarify the code and it would be more F# idiomatic. It's a simple modification, but it's structural. Maybe for the next version 3.
Tell me what you think.
And thank you again
The text was updated successfully, but these errors were encountered: