From 022847f3ae9f07024660cc92f60c7a505dc7017e Mon Sep 17 00:00:00 2001 From: Daniel Diaz <39510674+IslandRhythms@users.noreply.github.com> Date: Wed, 20 Apr 2022 16:55:49 -0400 Subject: [PATCH] fix: added necessary code --- index.d.ts | 5 +++++ index.js | 5 ++++- test/test.ts | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 index.d.ts create mode 100644 test/test.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..01c5d76 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,5 @@ +declare module "mongoose-lean-virtuals" { + import mongoose = require('mongoose'); + export default function mongooseLeanVirtuals(schema: mongoose.Schema, opts?: any): void; + export function mongooseLeanVirtuals(schema: mongoose.Schema, opts?: any): void; + } \ No newline at end of file diff --git a/index.js b/index.js index 6711edf..3e691c6 100644 --- a/index.js +++ b/index.js @@ -213,4 +213,7 @@ function attachVirtualsToDoc(schema, doc, virtuals) { function isPopulateVirtual(virtualType) { return virtualType.options && (virtualType.options.ref || virtualType.options.refPath); -} \ No newline at end of file +} + +module.exports.defaults = module.exports; +module.exports.mongooseLeanVirtuals = module.exports; \ No newline at end of file diff --git a/test/test.ts b/test/test.ts new file mode 100644 index 0000000..6c54f4d --- /dev/null +++ b/test/test.ts @@ -0,0 +1,17 @@ +import * as mongoose from 'mongoose'; +import * as mongooseLeanVirtuals from "mongoose-lean-virtuals"; + +interface Test { + name: string +} +/* +const testSchema = new mongoose.Schema({ + name: String +}); +*/ + +const testSchema = new mongoose.Schema({ + name: String +}); + +testSchema.plugin(mongooseLeanVirtuals.mongooseLeanVirtuals); \ No newline at end of file