Requesting clarification on the implementation of the default scope

14 vistas
Ir al primer mensaje no leído

Andrew Sidhu

no leída,
27 abr 2017, 1:21:47 p.m.27/4/17
para LoopbackJS
Hello,

Some background: I'm actively developing an alternative loopback connector for DynamoDB which fully supports composite keys as intended. This is forked from, but vastly different than Mandar Zope's implementation that is currently on NPM. Because Loopback does not have native support for composite primary keys, The connector has a custom DAO to support composite keys while maintaining backwards compatibility with the original DAO & other Databases.

I noticed that when a default scope has a where property given to it, I get a very unexpected result, as stated in the documentation and shown below:

base query:
{  "where":
          {"email":"jo...@doe.com"}
}

default scope:
{"realm":"users"}

result:

{ "where":  {
    "and":  [ { "email":"jo...@doe.com" }, { "realm":"users" } ]
  }
}

The result is generated when the DAO calls `MergeQuery(base, update, spec)` in utils.js


I changed it to gracefully merge in the DynamoDB connector's DAO so that it works cleanly with my connector (Commit - Excuse the commit message, I was quite frustrated at the time). However I am worried about backwards compatibility or if it was done like this for a specific reason (like security).

Can someone provide me with some clarification on why it merges as an array of queries? And if my implementation would break compatibility with other connectors? Other than the fact I am using ES6.

Thank you,

Andrew Sidhu
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos