deno.land / x / mongoose@6.7.5 / lib / helpers / query / wrapThunk.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const MongooseError = require('../../error/mongooseError');
/** * A query thunk is the function responsible for sending the query to MongoDB, * like `Query#_findOne()` or `Query#_execUpdate()`. The `Query#exec()` function * calls a thunk. The term "thunk" here is the traditional Node.js definition: * a function that takes exactly 1 parameter, a callback. * * This function defines common behavior for all query thunks. * @param {Function} fn * @api private */
module.exports = function wrapThunk(fn) { return function _wrappedThunk(cb) { if (this._executionStack != null) { let str = this.toString(); if (str.length > 60) { str = str.slice(0, 60) + '...'; } const err = new MongooseError('Query was already executed: ' + str); err.originalStack = this._executionStack.stack; return cb(err); } this._executionStack = new Error();
fn.call(this, cb); };};
mongoose

Version Info

Tagged at
a year ago