How to use the default function from mongoose

Find comprehensive JavaScript mongoose.default code examples handpicked from public code repositorys.

34
35
36
37
38
39
    created: Number,
    private: Boolean,
    owner: String,
    description: String
});
exports.default = mongoose_1.default.model('Playlists', PlaylistSchema);
fork icon5
star icon8
watch icon3

23
24
25
26
27
28
29
30
31
32
};
Object.defineProperty(exports, "__esModule", { value: true });
const mongoose_1 = __importStar(require("mongoose"));
const UserSchema = new mongoose_1.Schema({
    discordId: {
        type: mongoose_1.default.SchemaTypes.String,
        required: true,
        unique: true,
    },
    accessToken: { type: mongoose_1.default.SchemaTypes.String, required: true },
fork icon5
star icon8
watch icon3

+ 6 other calls in file

21
22
23
24
25
26
27
28
29
30
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const mongoose_1 = __importStar(require("mongoose"));
const CourseReviewSchema = new mongoose_1.default.Schema({
    course: {
        type: mongoose_1.Schema.Types.ObjectId,
        ref: "Course",
    },
fork icon0
star icon2
watch icon1

+ 7 other calls in file

91
92
93
94
95
96
            type: mongoose_1.Schema.Types.ObjectId,
            ref: "CourseReview",
        },
    ],
});
exports.default = mongoose_1.default.model("Course", CourseSchema);
fork icon0
star icon2
watch icon1

+ 7 other calls in file

51
52
53
54
55
56
57
58
59
60
    scoreEntry: {
        type: String,
    },
    predict: [
        {
            type: mongoose_1.default.Schema.Types.ObjectId,
            ref: "predicts",
        },
    ],
}, { timestamps: true });
fork icon2
star icon0
watch icon1

13
14
15
16
17
18
19
20
21
22
Object.defineProperty(exports, "__esModule", { value: true });
exports.User = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const validator_1 = __importDefault(require("validator"));
const bcryptjs_1 = __importDefault(require("bcryptjs"));
const UserSchema = new mongoose_1.default.Schema({
    name: {
        type: String,
        trim: true,
        required: [true, "Name is required"],
fork icon0
star icon0
watch icon1

+ 5 other calls in file

62
63
64
65
66
67
68
69
70
71
setup() {
    return __awaiter(this, void 0, void 0, function* () {
        if (!this.connected) {
            try {
                utils_1.logger.info(`Initiating Mongo DB connectivity...`);
                yield mongoose_1.default.connect(config_1.default.get(`kitchenService.db.connectionString`));
                utils_1.logger.info(`Connected to Mongo DB. Connection ID = ${mongoose_1.default.connection.id}`);
                this.connected = true;
                mongoose_1.default.connection.on(`disconnected`, () => {
                    utils_1.logger.info(`Mongo DB disconnect event triggered.`);
fork icon0
star icon0
watch icon1

+ 27 other calls in file

94
95
96
97
98
99
100
101
102
103
/*========================================================
# mongourl 
========================================================*/
_mongodb(options) { 
  if(options.setConnectMongoDB) {
    mongoose.default.connect(options.setMongoDB, { 
      useNewUrlParser: true, 
      useUnifiedTopology: true,
      useCreateIndex: true,
      useFindAndModify: false
fork icon0
star icon0
watch icon1

+ 8 other calls in file

72
73
74
75
76
77
78
79
80
81
        yield this.checkData();
    });
}
static connectMongo() {
    let uri = exports.settings.mongouri;
    mongoose_1.default.set('strictQuery', false);
    (0, mongoose_1.connect)(uri)
        .catch((err) => {
        try {
            throw new error_1.default("mongo:connect", `err=${err.message}; uri="${uri}"`);
fork icon0
star icon0
watch icon1

+ 3 other calls in file

996
997
998
999
1000
1001
1002
1003
1004
1005
// @ts-ignore
let hello = data.map((x) => new mongoose_1.default.mongo.ObjectId(x.ingredientId));
let selctedNutritions = [
    '620b4608b82695d67f28e19c',
    '620b4609b82695d67f28e19f',
].map((x) => new mongoose_1.default.mongo.ObjectId(x));
let ingredients;
ingredients = await blendIngredient_1.default.find({
    _id: { $in: hello },
    // status: 'Active',
fork icon0
star icon0
watch icon1

+ 3 other calls in file

75
76
77
78
79
80
81
82
83
84
var phone_1 = require("../models/phone");
var textResponses_1 = __importDefault(require("../textResponses"));
var email_1 = require("../../utils/email");
var urls_1 = __importDefault(require("../../utils/urls"));
var outgoingText_1 = require("./outgoingText");
var Feedback = mongoose_1.default.model('Feedback');
var Phone = mongoose_1.default.model('Phone');
var MessagingResponse = twilio_1.twiml.MessagingResponse;
var router = express_1.default.Router();
var DROPOFF_EMAIL_SUBSCRIBERS = [
fork icon0
star icon0
watch icon1

27
28
29
30
31
32
    name: {
        type: String,
        required: true,
    },
});
exports.default = mongoose_1.default.model("Category", categoriesSchema);
fork icon0
star icon0
watch icon1

+ 2 other calls in file

27
28
29
30
31
32
    name: {
        type: String,
        required: true,
    },
});
exports.default = mongoose_1.default.model("DefaultCategory", defaultCategoriesSchema);
fork icon0
star icon0
watch icon1

+ 2 other calls in file

23
24
25
26
27
28
29
30
31
32
};
Object.defineProperty(exports, "__esModule", { value: true });
const mongoose_1 = __importStar(require("mongoose"));
// Create a Schema corresponding to the document interface
const productSchema = new mongoose_1.Schema({
    _id: mongoose_1.default.Schema.Types.ObjectId,
    productName: { type: String, required: true },
    brand: { type: String, required: true },
    model: { type: String, required: true },
    price: { type: Number, required: true },
fork icon0
star icon0
watch icon1

23
24
25
26
27
28
29
30
31
32
};
Object.defineProperty(exports, "__esModule", { value: true });
const mongoose_1 = __importStar(require("mongoose"));
// Create a Schema corresponding to the document interface
const userSchema = new mongoose_1.Schema({
    _id: { type: mongoose_1.default.Schema.Types.ObjectId, auto: true },
    firstname: { type: String, required: true },
    surname: { type: String, required: true },
    gender: {
        type: String,
fork icon0
star icon0
watch icon1

173
174
175
176
177
178
179
180
181
182
        }
    }
}
else {
    planners.push({
        _id: new mongoose_1.default.mongo.ObjectId(),
        memberId: userId,
        recipes: [],
        formatedDate: (0, FormateDate_1.default)(tempDay),
    });
fork icon0
star icon0
watch icon1

+ 8 other calls in file

21
22
23
24
25
26
27
28
29
30
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const mongoose_1 = __importStar(require("mongoose"));
const categorySchema = new mongoose_1.default.Schema({
    name: {
        type: String,
        min: [3, 'must be greater than three digit'],
        max: [25, 'mesage from name'],
fork icon0
star icon0
watch icon1

+ 3 other calls in file

31
32
33
34
35
36
37
        type: mongoose_1.Schema.Types.ObjectId
    },
    total_grade: Number,
    student_grade: Number
});
const ResultModel = mongoose_1.default.model('Result', ResultSchema);
exports.default = ResultModel;
fork icon0
star icon0
watch icon1

+ 3 other calls in file

21
22
23
24
25
26
27
28
29
30
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const mongoose_1 = __importStar(require("mongoose"));
const bookSchema = new mongoose_1.default.Schema({
    name: {
        type: String,
        min: [3, 'must be greater than three digit'],
        max: [25, 'not allow to be more than 25 digit'],
fork icon0
star icon0
watch icon1

279
280
281
282
283
284
285
286
287
288
//@ts-ignore
(iw) => String(iw.memberId) === memberId)[0];
if (!data) {
    return new AppError_1.default('Invalid invite', 400);
}
let mongoMemberId = new mongoose_1.default.mongo.ObjectId(memberId.toString());
await InviteForChallenge_1.default.findOneAndUpdate({ _id: inviteId }, {
    $pull: {
        'sharedWith.memberId': mongoMemberId,
    },
fork icon0
star icon0
watch icon1

+ 71 other calls in file