New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plans for [<BsonIgnore>] #26
Comments
Hello @srlopez, I finally got around and made allocated some time to work on these issues. Ok, first of all the type Disk = { SizeGb : int }
type Computer =
{ Id: int
Manufacturer: string
Disks: Disk list }
with member this.Ignored = sprintf "%d => %s" this.Id this.Manufacturer here you see the member This is an interesting case of separating data and behavior from each other. If you want to introduce F# to your students, it is better to showcase best practices with idiomatic F# code: no mutation, only data transformations. here is a full example: // Learn more about F# at http://fsharp.org
open LiteDB
open LiteDB.FSharp
open System.IO
[<CLIMutable>]
type Disk =
{ SizeGb : int }
[<CLIMutable>]
type Computer =
{ Id: int
Manufacturer: string
Disks: Disk list }
// this is not persisted
with member this.Ignored = sprintf "%d => %s" this.Id this.Manufacturer
[<EntryPoint>]
let main argv =
let myPc =
{ Id = 0
Manufacturer = "Computers Inc."
Disks =
[ { SizeGb = 100 }
{ SizeGb = 250 }
{ SizeGb = 500 } ] }
let mapper = FSharpBsonMapper()
use memoryStream = new MemoryStream()
use db = new LiteDatabase(memoryStream, mapper)
let computers = db.GetCollection<Computer>("computers")
// Insert & Print
computers.Insert(myPc) |> ignore
let insertedPc = computers.FindAll() |> Seq.head
printfn "%A, %s" insertedPc insertedPc.Ignored
0 Notice I am using |
You are right. |
Without
As you can see, member |
I build a lot of these "wrappers" and usually I try to take just the good parts that make sense to use within F#
Have you updated your nuget of |
OMG!
and now |
Glad to hear that it is working! 😄 I will consider this issue as resolved, if you encounter any problem or need any help, just let know! Cheers |
* Introduce auto-quoted query expressions, publish 2.7.0 * Support mutable values -> fixes Zaid-Ajaj#27. Take back control of record marshalling * Add tests for ignored members just to be sure, see Zaid-Ajaj#26 * Add support for literal boolean values in query expressions * Support comparison operators for id fields by @humhei at Zaid-Ajaj#31
Hello, as you can see in the F# forum. Studying how to introduce my students in F#, we were converting a small java project to F#, and to avoid philosophical discussions about SQL and ORM, LiteDB is the perfect solution. But the attributes calculated according to other attributes are also saved in LiteDB, we have used
[<BsonIgnore>]
(on BsonMapper.cs Line 252,) but we have already seen that there is no account.You have plans to implement it.
And what about
[<BsonField>]
?The text was updated successfully, but these errors were encountered: