Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
q3-plugin-extref
Advanced tools
This plugin implements the [Extended Reference Pattern](https://www.mongodb.com/blog/post/building-with-patterns-the-extended-reference-pattern) to reduce lookups in your code. It connects to Mongoose's save middleware, so it will not fire on update op
Readme
This plugin implements the Extended Reference Pattern to reduce lookups in your code. It connects to Mongoose's save middleware, so it will not fire on update operations. It also relies on Q3's archiving functionality, so it will only pull or unset on specific document changes.
// FILE #1
const mongoose = require('mongoose');
const { ExtendedReference } = require('q3-plugin-extref');
const ReferenceSchema = new mongoose.Schema({
name: String,
age: Number,
});
// tells the plugin which collections to update on save
ReferenceSchema.plugin(ExtendedReference.plugin, [
'TARGETS',
]);
module.exports = mongoose.model('DEMO_ONLY', ReferenceSchema);
// FILE #2
const mongoose = require('mongoose');
const { ExtendedReference } = require('q3-plugin-extref');
const ReferenceModel = require('./reference');
const TargetSchema = new mongoose.Schema({
friend: new ExtendedReference('DEMO_ONLY')
.on(['name', 'age'])
.set('name', { private: true })
.done(),
// Saves as:
// {
// ref: ObjectId(),
// name: 'Example',
// age: 21
// }
});
module.exports = mongoose.model('TARGETS', TargetSchema);
Alternatively, this plugin also ships with a very basic autopopulation feature.
const mongoose = require('mongoose');
const { autopopulate } = require('q3-plugin-extref');
const TargetSchema = new mongoose.Schema({
email: {
type: String,
unique: true,
autopopulate: true,
autopopulateSelect: 'projection path',
ref: 'DEMO_ONLY'
}
});
TargetSchema.plugin(autopopulate)
FAQs
This plugin implements the [Extended Reference Pattern](https://www.mongodb.com/blog/post/building-with-patterns-the-extended-reference-pattern) to reduce lookups in your code. It connects to Mongoose's save middleware, so it will not fire on update op
The npm package q3-plugin-extref receives a total of 16 weekly downloads. As such, q3-plugin-extref popularity was classified as not popular.
We found that q3-plugin-extref 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.