Skip to content
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

ReadFilter not working #538

Open
shoyebinamdar opened this issue Jul 24, 2021 · 0 comments
Open

ReadFilter not working #538

shoyebinamdar opened this issue Jul 24, 2021 · 0 comments

Comments

@shoyebinamdar
Copy link

shoyebinamdar commented Jul 24, 2021

Hi Team,

I am referring to the README.md, and I have created a sample program to read and write from threaddb.
I also want to test out WriteValidator and ReadFilter. But ReadFilter is not working for me. I tried to use following snippet as defined in README.md.

err := db.NewCollection(context.Background(), myThreadID, db.CollectionConfig{
    Name:    "Persons",
    Schema:  mySchema,
    Indexes: []db.Index{{
        Path:   "name",
		Unique: true,
    }},
    WriteValidator: 
        var type = event.patch.type
        var patch = event.patch.json_patch
        switch (type) {
          case "delete":
            if (writer != "the_boss") {
              return false // Not the boss? No deletes for you.
            }
          default:
            return true
        }
    ,
    ReadFilter: 
        if (instance.Age > 50) {
            delete instance.Age // Getting old, let's hide just _how_ old hehe
        }
        return instance
    ,
})

Please help me here.
What am I doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant