Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
baucis-decorator-deep-select
Advanced tools
Adds automatic deep populate + select functionality.
npm install baucis-decorators baucis-decorator-deep-select --save
Just add the decorator and it should work if you're using a version of mongoose
that supports deep population. The latest release does not yet support this but 4.2 should. Until then, this decorator will patch mongoose/lib/utils
and mongoose/lib/model
to support deep population.
controllers/Comment.js
var baucis = require('baucis');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = Schema.Types.ObjectId;
var CommentProps = {};
CommentProps.by = {
type: ObjectId,
ref: 'User'
};
CommentProps.comment = {
type: String
};
CommentProps.replies = {
type: [{
type: ObjectId,
ref: 'Comment'
}]
};
var CommentSchema = new Schema(CommentProps);
var CommentModel = mongoose.model('Comment', CommentSchema);
var CommentController = baucis.rest('Comment');
var decorators = require('baucis-decorators');
decorators.add.call(CommentController, [
'baucis-decorator-deep-select'
]);
/**
* Expose controller.
*/
module.exports = CommentController;
Then to select and populate some comments a few levels deep, GET a URL as follows.
From single comment:
localhost:8080/api/comments/123?select=replies.replies.replies
From query:
localhost:8080/api/comments?by=someUserId&select=replies.replies.replies
Or select certain fields:
localhost:8080/api/comments?by=someUserId&select=comment by.name by.image comment replies.comment replies.replies.comment replies.replies.replies.comment
This should pair quite well with something that might convert a GraphQL-like string to the above select
parameters.
FAQs
Adds automatic deep populate + select functionality.
The npm package baucis-decorator-deep-select receives a total of 0 weekly downloads. As such, baucis-decorator-deep-select popularity was classified as not popular.
We found that baucis-decorator-deep-select demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.