Skip to content

Commit

Permalink
fix: added necessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
IslandRhythms committed Apr 20, 2022
1 parent 7088e74 commit 022847f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module "mongoose-lean-virtuals" {
import mongoose = require('mongoose');
export default function mongooseLeanVirtuals(schema: mongoose.Schema<any, any, any, any>, opts?: any): void;
export function mongooseLeanVirtuals(schema: mongoose.Schema<any, any, any, any>, opts?: any): void;
}
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,7 @@ function attachVirtualsToDoc(schema, doc, virtuals) {

function isPopulateVirtual(virtualType) {
return virtualType.options && (virtualType.options.ref || virtualType.options.refPath);
}
}

module.exports.defaults = module.exports;
module.exports.mongooseLeanVirtuals = module.exports;
17 changes: 17 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
@@ -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<Test>({
name: String
});

testSchema.plugin(mongooseLeanVirtuals.mongooseLeanVirtuals);

0 comments on commit 022847f

Please sign in to comment.