Skip to content

"loaded" opertation observer -- either docs are incorrect or implementation is buggy #1843

Description

@dregre

The docs say, in relation to the loaded operation hook:

LoopBack invokes this hook after the connector fetches data, but before creating a model instance from that data. This enables hooks to decrypt data (for example). NOTE: This hook is called with the raw database data, not a full model instance. (My emphasis)

However, after attaching a debugger and inspecting the ctx returned to my loaded callback, I've noticed that:

  1. The ctx object has no data property at all;
  2. Contrary to what the description says, it does contain a model instance.

E.g.:

MyModel.observe('loaded', function(ctx, next){
    console.log(ctx); // Added a breakpoint here.  Inspected `ctx`.
                      // Does contain `instance`.  Doesn't contain `data`.
    next();
});

I'm not sure whether the documentation is incorrect or the implementation is buggy?

Metadata

Metadata

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions