loopback-next icon indicating copy to clipboard operation
loopback-next copied to clipboard

Hidden properties

Open wohldani opened this issue 8 years ago • 37 comments

Description / Steps to reproduce / Feature proposal

Does Loopback 4 supports hidden properties like LB3 did?

Current Behavior

I could not find any docs or resources about this.

Expected Behavior

https://loopback.io/doc/en/lb3/Model-definition-JSON-file.html#hidden-properties

wohldani avatar Oct 25 '18 19:10 wohldani

@bajtos Thanks. Will see how can I help @frbuceta on this. I am on vacation on coming few days. Will start on it next week.

bhupesh-sf avatar Jun 28 '19 12:06 bhupesh-sf

@frbuceta let me know how can I help you on this. The current solution is a short-term solution but I believe we should enhance it to full blown solution?

bhupesh-sf avatar Jun 28 '19 12:06 bhupesh-sf

@bhupesh-sf I'm beginning to understand how this is going. But yes, we can work on a better solution

frbuceta avatar Jun 28 '19 13:06 frbuceta

@bajtos Although its not related to the current issue but do you think to have internal properties for the model. Use case could be some kind of calculated properties which can be only internally created/updated and I don't want them to be the part of request but of the response??

Syntax could be something like

{ name: orderTotal, isInternal: true }

bhupesh-sf avatar Jun 28 '19 13:06 bhupesh-sf

@frbuceta, since your PR #3304 has landed, is this issue good to close? Thanks.

dhmlau avatar Dec 16 '19 00:12 dhmlau

@frbuceta, since your PR #3304 has landed, is this issue good to close? Thanks.

Yes, it can be closed. Something provisional has been launched to my liking but someday the time will come to do it better

frbuceta avatar Dec 16 '19 00:12 frbuceta

This problem is solved? I still have the same problem. I put the decorator in model:

@model({
  settings: {
    hiddenProperties: ['Password'],
    strict: false,
  },
})

and the response still show de Password property.

image

joel-izaguirre avatar May 14 '20 21:05 joel-izaguirre

This problem is solved? I still have the same problem. I put the decorator in model:

@model({
  settings: {
    hiddenProperties: ['Password'],
    strict: false,
  },
})

and the response still show de Password property.

image

I don't know what exactly is happening but it works for me

@model({
  name: 'users',
  settings: {
    hiddenProperties: ['password'],
  },
})
export class User extends Entity {
...

  @property({
    type: 'string',
    required: true,
    jsonSchema: {
      minLength: 8,
    },
  })
  password: string;

...
}

frbuceta avatar May 14 '20 23:05 frbuceta

The problem is with de setting "strict: false", if eliminate that, works well, Is it normal or is an error?

joel-izaguirre avatar May 15 '20 01:05 joel-izaguirre

The problem is with de setting "strict: false", if eliminate that, works well, Is it normal or is an error?

I investigate it

frbuceta avatar May 15 '20 14:05 frbuceta

@joel-izaguirre In the next version of LoopBack (in a few days) it will work

frbuceta avatar May 18 '20 21:05 frbuceta

@joel-izaguirre In the next version of LoopBack (in a few days) it will work

Still not working, or I miss something?

mycolaos avatar Oct 07 '20 12:10 mycolaos

@mycolaos, how are you using the hiddenProperties? Could you please take a look at https://github.com/strongloop/loopback-next/issues/6385?

dhmlau avatar Oct 07 '20 14:10 dhmlau

@dhmlau like this:

@model({
  settings: {
    hiddenProperties: ['password']
  }
})

mycolaos avatar Oct 07 '20 15:10 mycolaos

Reopening this issue to be able to track this issue.

@mycolaos, I just tried it with the latest LB4 modules and seems to be working for me. My Customer model has:

  • custId
  • name
  • password <-- hidden property, defined the same way as you did.

Then I tested it with API explorer,

  1. POST
{
  "name": "name1",
  "password": "pwd1"
}
  1. GET
[
  {
    "custId": "1",
    "name": "name1"
  }
]

Is it what you're seeing too?

dhmlau avatar Oct 07 '20 16:10 dhmlau

@dhmlau I believe I found the problem. I have an abstract class MyEntity that is than extended by other models. MyEntity has the hiddenProperties options, but it doesn't work. If I decorate with hiddenProperties the final model that extends MyEntity - it works.

Then, how I can make it work with MyEntity?

mycolaos avatar Oct 08 '20 12:10 mycolaos

@model({ settings: { hiddenProperties: ['OTP', 'providerId', 'password', 'isDelete'], }, })

This is worked for me., try this

durai001 avatar Jun 13 '21 10:06 durai001