Hiding some fields in the return model

Is there a way to hide some fields in the returned model after the document has been created?

For example, I do not want the email verification code to be returned after the user has been created. How can I do that?

Hi,

you can use index with values.

CreateIndex({
  name: "Users_all",
  source: Collection("users"),
  values: [
    {field: ["data", "name"]},
    {field: ["data", "lastName"]},
    {field: ["data", "email"]},
    {field: ["data", "activated"]}
  ],
  terms: [ ]
})

Hi, thank you.

I do not withdraw data through an index.
This is the result returned after the create operation.
I think this index works when we call itself?

can use Let when create User.

Let({
  userRef: Select(['ref'], Create(Collection('users'), {data: {name: 'hello world', email: 'hello@fauna.com', password:'123'}})),
  userWithoutPassword: Paginate(Match('user_without_password', Var('userRef')))
}, {
  result: Select([0], Var('userWithoutPassword'))
}
)
CreateIndex({
  name: "user_without_password",
  source: Collection("users"),
  terms: [
    {field: ["ref"]}
  ],
  values: [{field: ['data','name']}, {field: ['data','email']}]
})

can trying some like this.

Understood,
So we do two things. Creation and Selection.
For now, I’ve filtered it in the api app.
In situations where I directly access fauna, I use this method if necessary.

Thank you

Hi @hasimyerlikaya,

or something like this:

 Let(
  {
    create: Create(Collection('users'),
      {
        data:
          {
            name:"test",
            lastName: "user",
            email: "testuser@mail.com",
            activation: false,
            emailVerified: false,
            emailVerificationCode: "435fdgfd-5fh87-dvgt-5r4f-dfbgazxtr667hgfb6"
          }
        }
      )
  },
  Merge(Select(['data'],Var('create')),{emailVerificationCode: null})
)

Luigi

2 Likes

This seems like a more effective solution.
I now understand better how powerful FQL is :slight_smile:
Thank you.

1 Like

FQL is awesome!!!

Everyday i learn new stuffs. :nerd_face:

for example, Merge with field null

2 Likes

What email service are you using to verify emails? I am currently working on this and am trying to find a valid solution?

I also needed an email provider.
After some digging, I decided to use https://mailchimp.com.

Okay cool thank you. I will try and work with their API.

By any chance have you worked out the logic of allowing a verification code to have a time expiry?

I don’t know if there is such a feature in Mailchimp. As I want to manage this process myself, I don’t need much.

Setting a deadline for email verification is unnecessary for my needs. But password reset is also required.

For this, the code sent in the password renewal procedure + the expiry time should be kept. It should send mail via Mailchimp and there should be a link in it. When the link is clicked, a page created by us should open and the necessary controls should be made there.