Mongo Error When Calling destroyAll

323 views
Skip to first unread message

Christopher Moffatt

unread,
Apr 21, 2015, 8:58:36 PM4/21/15
to loopb...@googlegroups.com
I am getting an "unknown operator: $principalId" when executing the code below.  I cannot figure out why.

var RoleMapping = app.models.RoleMapping;
RoleMapping.destroyAll( { where: { principalId: userId } }, function(err, obj)
{
 
...
} );
;

Raymond Feng

unread,
Apr 21, 2015, 10:43:56 PM4/21/15
to Christopher Moffatt, loopb...@googlegroups.com
Please remove the 'where' layer. destroyAll takes the where value directly.

Sent from my iPhone 6 Plus
--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christopher Moffatt

unread,
Apr 21, 2015, 11:23:59 PM4/21/15
to loopb...@googlegroups.com, clmo...@gmail.com
Thanks, that worked!
Message has been deleted

Tami Wright

unread,
Jul 23, 2015, 6:08:05 PM7/23/15
to LoopbackJS, clmo...@gmail.com, ray...@strongloop.com
You should update the docs at http://apidocs.strongloop.com/loopback/#persistedmodel-destroyall to reflect that 
destroyAll takes the where value directly

Rand McKinney

unread,
Aug 3, 2015, 6:17:51 PM8/3/15
to LoopbackJS, clmo...@gmail.com, ray...@strongloop.com
The API docs actually reflect the correct syntax, although I agree they could be clearer.  The signature given is PersistedModel.destroyAll([where], callback) with [where] given as {key: val, key2: {gt: 'val2'}, ...}

I added a new section to there Where filter article to highlight that the where clause has slightly different form for queries and update/delete operations; and some cress-reference notes in Creating, updating, and deleting data.  I'll try to clarify the API docs as well.

Thanks,
Rand  

Raymond Feng

unread,
Aug 3, 2015, 6:21:42 PM8/3/15
to Rand McKinney, LoopbackJS, clmo...@gmail.com
FYI, Rand. The issue was raised before I fixed the jsdoc - https://github.com/strongloop/loopback/commit/0f9dd93abacf451f09fff9a6d99ec4d13d1c2a29.

Thanks,

---
Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.

StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

Rand McKinney

unread,
Aug 3, 2015, 6:31:32 PM8/3/15
to LoopbackJS, ra...@strongloop.com, clmo...@gmail.com
My bad.  I was out last week, and didn't realize that Raymond had made that fix.
Thanks for bringing it to our attention.

Thanks,
Rand

Tami Wright

unread,
Aug 5, 2015, 5:32:22 PM8/5/15
to loopb...@googlegroups.com, ra...@strongloop.com, clmo...@gmail.com
Sure thing!

--
You received this message because you are subscribed to a topic in the Google Groups "LoopbackJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/loopbackjs/31UMZfmCvmE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/62020389-53bf-4296-9f01-4d13875f5e88%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
>>>>>>>>><<<<<<<<<
Tami Thompson Wright
(801) 709-4401 (Cell)
(440) 508-4972 (Land-line)
Reply all
Reply to author
Forward
0 new messages