id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6,400 | deepstreamIO/deepstream.io | src/record/record-handler.js | sendRecord | function sendRecord (recordName, record, socketWrapper) {
socketWrapper.sendMessage(RECORD, C.ACTIONS.READ, [recordName, record._v, record._d])
} | javascript | function sendRecord (recordName, record, socketWrapper) {
socketWrapper.sendMessage(RECORD, C.ACTIONS.READ, [recordName, record._v, record._d])
} | [
"function",
"sendRecord",
"(",
"recordName",
",",
"record",
",",
"socketWrapper",
")",
"{",
"socketWrapper",
".",
"sendMessage",
"(",
"RECORD",
",",
"C",
".",
"ACTIONS",
".",
"READ",
",",
"[",
"recordName",
",",
"record",
".",
"_v",
",",
"record",
".",
"... | Sends the records data current data once done
@param {String} recordName
@param {Object} record
@param {SocketWrapper} socketWrapper the socket that send the request
@private
@returns {void} | [
"Sends",
"the",
"records",
"data",
"current",
"data",
"once",
"done"
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/record/record-handler.js#L710-L712 |
6,401 | deepstreamIO/deepstream.io | src/event/event-handler.js | validateSubscriptionMessage | function validateSubscriptionMessage (socket, message) {
if (message.data && message.data.length === 1 && typeof message.data[0] === 'string') {
return true
}
socket.sendError(C.TOPIC.EVENT, C.EVENT.INVALID_MESSAGE_DATA, message.raw)
return false
} | javascript | function validateSubscriptionMessage (socket, message) {
if (message.data && message.data.length === 1 && typeof message.data[0] === 'string') {
return true
}
socket.sendError(C.TOPIC.EVENT, C.EVENT.INVALID_MESSAGE_DATA, message.raw)
return false
} | [
"function",
"validateSubscriptionMessage",
"(",
"socket",
",",
"message",
")",
"{",
"if",
"(",
"message",
".",
"data",
"&&",
"message",
".",
"data",
".",
"length",
"===",
"1",
"&&",
"typeof",
"message",
".",
"data",
"[",
"0",
"]",
"===",
"'string'",
")",... | Makes sure that subscription message contains the name of the event. Sends an error to the client
if not
@param {SocketWrapper} socket
@param {Object} message parsed and permissioned deepstream message
@private
@returns {Boolean} is valid subscription message | [
"Makes",
"sure",
"that",
"subscription",
"message",
"contains",
"the",
"name",
"of",
"the",
"event",
".",
"Sends",
"an",
"error",
"to",
"the",
"client",
"if",
"not"
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/event/event-handler.js#L127-L135 |
6,402 | deepstreamIO/deepstream.io | src/permission/config-compiler.js | compileRuleset | function compileRuleset (path, rules) {
const ruleset = pathParser.parse(path)
ruleset.rules = {}
for (const ruleType in rules) {
ruleset.rules[ruleType] = ruleParser.parse(
rules[ruleType], ruleset.variables
)
}
return ruleset
} | javascript | function compileRuleset (path, rules) {
const ruleset = pathParser.parse(path)
ruleset.rules = {}
for (const ruleType in rules) {
ruleset.rules[ruleType] = ruleParser.parse(
rules[ruleType], ruleset.variables
)
}
return ruleset
} | [
"function",
"compileRuleset",
"(",
"path",
",",
"rules",
")",
"{",
"const",
"ruleset",
"=",
"pathParser",
".",
"parse",
"(",
"path",
")",
"ruleset",
".",
"rules",
"=",
"{",
"}",
"for",
"(",
"const",
"ruleType",
"in",
"rules",
")",
"{",
"ruleset",
".",
... | Compiles an individual ruleset
@param {String} path
@param {Object} rules
@private
@returns {Object} compiledRuleset | [
"Compiles",
"an",
"individual",
"ruleset"
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/permission/config-compiler.js#L42-L54 |
6,403 | deepstreamIO/deepstream.io | src/record/record-request.js | sendError | function sendError (
event, message, recordName, socketWrapper, onError, options, context, metaData
) {
options.logger.error(event, message, metaData)
if (socketWrapper) {
socketWrapper.sendError(C.TOPIC.RECORD, event, message)
}
if (onError) {
onError.call(context, event, message, recordName, socketW... | javascript | function sendError (
event, message, recordName, socketWrapper, onError, options, context, metaData
) {
options.logger.error(event, message, metaData)
if (socketWrapper) {
socketWrapper.sendError(C.TOPIC.RECORD, event, message)
}
if (onError) {
onError.call(context, event, message, recordName, socketW... | [
"function",
"sendError",
"(",
"event",
",",
"message",
",",
"recordName",
",",
"socketWrapper",
",",
"onError",
",",
"options",
",",
"context",
",",
"metaData",
")",
"{",
"options",
".",
"logger",
".",
"error",
"(",
"event",
",",
"message",
",",
"metaData"... | Sends an error to the socketWrapper that requested the
record | [
"Sends",
"an",
"error",
"to",
"the",
"socketWrapper",
"that",
"requested",
"the",
"record"
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/record/record-request.js#L9-L19 |
6,404 | deepstreamIO/deepstream.io | src/record/record-request.js | onStorageResponse | function onStorageResponse (
error, record, recordName, socketWrapper, onComplete, onError, options, context, metaData
) {
if (error) {
sendError(
C.EVENT.RECORD_LOAD_ERROR,
`error while loading ${recordName} from storage:${error.toString()}`,
recordName,
socketWrapper,
onError,
... | javascript | function onStorageResponse (
error, record, recordName, socketWrapper, onComplete, onError, options, context, metaData
) {
if (error) {
sendError(
C.EVENT.RECORD_LOAD_ERROR,
`error while loading ${recordName} from storage:${error.toString()}`,
recordName,
socketWrapper,
onError,
... | [
"function",
"onStorageResponse",
"(",
"error",
",",
"record",
",",
"recordName",
",",
"socketWrapper",
",",
"onComplete",
",",
"onError",
",",
"options",
",",
"context",
",",
"metaData",
")",
"{",
"if",
"(",
"error",
")",
"{",
"sendError",
"(",
"C",
".",
... | Callback for responses returned by the storage connector. The request will complete or error
here, if the record couldn't be found in storage no further attempts to retrieve it will be made | [
"Callback",
"for",
"responses",
"returned",
"by",
"the",
"storage",
"connector",
".",
"The",
"request",
"will",
"complete",
"or",
"error",
"here",
"if",
"the",
"record",
"couldn",
"t",
"be",
"found",
"in",
"storage",
"no",
"further",
"attempts",
"to",
"retri... | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/record/record-request.js#L25-L46 |
6,405 | deepstreamIO/deepstream.io | src/record/record-request.js | onCacheResponse | function onCacheResponse (
error, record, recordName, socketWrapper, onComplete, onError, options, context, metaData
) {
if (error) {
sendError(
C.EVENT.RECORD_LOAD_ERROR,
`error while loading ${recordName} from cache:${error.toString()}`,
recordName,
socketWrapper,
onError,
... | javascript | function onCacheResponse (
error, record, recordName, socketWrapper, onComplete, onError, options, context, metaData
) {
if (error) {
sendError(
C.EVENT.RECORD_LOAD_ERROR,
`error while loading ${recordName} from cache:${error.toString()}`,
recordName,
socketWrapper,
onError,
... | [
"function",
"onCacheResponse",
"(",
"error",
",",
"record",
",",
"recordName",
",",
"socketWrapper",
",",
"onComplete",
",",
"onError",
",",
"options",
",",
"context",
",",
"metaData",
")",
"{",
"if",
"(",
"error",
")",
"{",
"sendError",
"(",
"C",
".",
"... | Callback for responses returned by the cache connector
@private
@returns {void} | [
"Callback",
"for",
"responses",
"returned",
"by",
"the",
"cache",
"connector"
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/record/record-request.js#L54-L104 |
6,406 | deepstreamIO/deepstream.io | src/record/json-path.js | setValue | function setValue (root, path, value) {
const tokens = tokenize(path)
let node = root
let i
for (i = 0; i < tokens.length - 1; i++) {
const token = tokens[i]
if (node[token] !== undefined && typeof node[token] === 'object') {
node = node[token]
} else if (typeof tokens[i + 1] === 'number') {... | javascript | function setValue (root, path, value) {
const tokens = tokenize(path)
let node = root
let i
for (i = 0; i < tokens.length - 1; i++) {
const token = tokens[i]
if (node[token] !== undefined && typeof node[token] === 'object') {
node = node[token]
} else if (typeof tokens[i + 1] === 'number') {... | [
"function",
"setValue",
"(",
"root",
",",
"path",
",",
"value",
")",
"{",
"const",
"tokens",
"=",
"tokenize",
"(",
"path",
")",
"let",
"node",
"=",
"root",
"let",
"i",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"tokens",
".",
"length",
"-",
"1",
... | This class allows to set or get specific
values within a json data structure using
string-based paths
@param {String} path A path, e.g. users[2].firstname
@constructor | [
"This",
"class",
"allows",
"to",
"set",
"or",
"get",
"specific",
"values",
"within",
"a",
"json",
"data",
"structure",
"using",
"string",
"-",
"based",
"paths"
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/record/json-path.js#L14-L32 |
6,407 | deepstreamIO/deepstream.io | src/record/json-path.js | tokenize | function tokenize (path) {
const tokens = []
const parts = path.split('.')
for (let i = 0; i < parts.length; i++) {
const part = parts[i].trim()
if (part.length === 0) {
continue
}
const arrayIndexes = part.split(SPLIT_REG_EXP)
tokens.push(arrayIndexes[0])
for (let j = 1; j < a... | javascript | function tokenize (path) {
const tokens = []
const parts = path.split('.')
for (let i = 0; i < parts.length; i++) {
const part = parts[i].trim()
if (part.length === 0) {
continue
}
const arrayIndexes = part.split(SPLIT_REG_EXP)
tokens.push(arrayIndexes[0])
for (let j = 1; j < a... | [
"function",
"tokenize",
"(",
"path",
")",
"{",
"const",
"tokens",
"=",
"[",
"]",
"const",
"parts",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"parts",
".",
"length",
";",
"i",
"++",
")",
"{",
... | Parses the path. Splits it into
keys for objects and indices for arrays.
@private
@returns {void} | [
"Parses",
"the",
"path",
".",
"Splits",
"it",
"into",
"keys",
"for",
"objects",
"and",
"indices",
"for",
"arrays",
"."
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/record/json-path.js#L41-L66 |
6,408 | deepstreamIO/deepstream.io | src/config/config-initialiser.js | handleSSLProperties | function handleSSLProperties (config) {
const sslFiles = ['sslKey', 'sslCert', 'sslDHParams']
let key
let resolvedFilePath
let filePath
for (let i = 0; i < sslFiles.length; i++) {
key = sslFiles[i]
filePath = config[key]
if (!filePath) {
continue
}
resolvedFilePath = fileUtils.lookup... | javascript | function handleSSLProperties (config) {
const sslFiles = ['sslKey', 'sslCert', 'sslDHParams']
let key
let resolvedFilePath
let filePath
for (let i = 0; i < sslFiles.length; i++) {
key = sslFiles[i]
filePath = config[key]
if (!filePath) {
continue
}
resolvedFilePath = fileUtils.lookup... | [
"function",
"handleSSLProperties",
"(",
"config",
")",
"{",
"const",
"sslFiles",
"=",
"[",
"'sslKey'",
",",
"'sslCert'",
",",
"'sslDHParams'",
"]",
"let",
"key",
"let",
"resolvedFilePath",
"let",
"filePath",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",... | Load the SSL files
CLI arguments will be considered.
@param {Object} config deepstream configuration object
@private
@returns {void} | [
"Load",
"the",
"SSL",
"files",
"CLI",
"arguments",
"will",
"be",
"considered",
"."
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/config/config-initialiser.js#L68-L86 |
6,409 | deepstreamIO/deepstream.io | src/config/config-initialiser.js | handleLogger | function handleLogger (config) {
const configOptions = (config.logger || {}).options
let Logger
if (config.logger == null || config.logger.name === 'default') {
Logger = DefaultLogger
} else {
Logger = resolvePluginClass(config.logger, 'logger')
}
if (configOptions instanceof Array) {
// Note: ... | javascript | function handleLogger (config) {
const configOptions = (config.logger || {}).options
let Logger
if (config.logger == null || config.logger.name === 'default') {
Logger = DefaultLogger
} else {
Logger = resolvePluginClass(config.logger, 'logger')
}
if (configOptions instanceof Array) {
// Note: ... | [
"function",
"handleLogger",
"(",
"config",
")",
"{",
"const",
"configOptions",
"=",
"(",
"config",
".",
"logger",
"||",
"{",
"}",
")",
".",
"options",
"let",
"Logger",
"if",
"(",
"config",
".",
"logger",
"==",
"null",
"||",
"config",
".",
"logger",
"."... | Initialize the logger and overwrite the root logLevel if it's set
CLI arguments will be considered.
@param {Object} config deepstream configuration object
@private
@returns {void} | [
"Initialize",
"the",
"logger",
"and",
"overwrite",
"the",
"root",
"logLevel",
"if",
"it",
"s",
"set",
"CLI",
"arguments",
"will",
"be",
"considered",
"."
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/config/config-initialiser.js#L97-L131 |
6,410 | deepstreamIO/deepstream.io | src/config/config-initialiser.js | resolvePluginClass | function resolvePluginClass (plugin, type) {
// alias require to trick nexe from bundling it
const req = require
let requirePath
let pluginConstructor
if (plugin.path != null) {
requirePath = fileUtils.lookupLibRequirePath(plugin.path)
pluginConstructor = req(requirePath)
} else if (plugin.name != n... | javascript | function resolvePluginClass (plugin, type) {
// alias require to trick nexe from bundling it
const req = require
let requirePath
let pluginConstructor
if (plugin.path != null) {
requirePath = fileUtils.lookupLibRequirePath(plugin.path)
pluginConstructor = req(requirePath)
} else if (plugin.name != n... | [
"function",
"resolvePluginClass",
"(",
"plugin",
",",
"type",
")",
"{",
"// alias require to trick nexe from bundling it",
"const",
"req",
"=",
"require",
"let",
"requirePath",
"let",
"pluginConstructor",
"if",
"(",
"plugin",
".",
"path",
"!=",
"null",
")",
"{",
"... | Instantiate the given plugin, which either needs a path property or a name
property which fits to the npm module name convention. Options will be passed
to the constructor.
CLI arguments will be considered.
@param {Object} config deepstream configuration object
@private
@returns {Function} Instance return be the plu... | [
"Instantiate",
"the",
"given",
"plugin",
"which",
"either",
"needs",
"a",
"path",
"property",
"or",
"a",
"name",
"property",
"which",
"fits",
"to",
"the",
"npm",
"module",
"name",
"convention",
".",
"Options",
"will",
"be",
"passed",
"to",
"the",
"constructo... | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/config/config-initialiser.js#L235-L254 |
6,411 | deepstreamIO/deepstream.io | bin/installer.js | function (urlPath, outStream, callback) {
needle.get(`https://github.com${urlPath}`, {
follow_max: 5,
headers: { 'User-Agent': 'nodejs-client' }
}, (error, response) => {
if (error) {
return callback(error)
}
outStream.write(response.body)
outStream.end()
if (process.env.VERBOSE) {... | javascript | function (urlPath, outStream, callback) {
needle.get(`https://github.com${urlPath}`, {
follow_max: 5,
headers: { 'User-Agent': 'nodejs-client' }
}, (error, response) => {
if (error) {
return callback(error)
}
outStream.write(response.body)
outStream.end()
if (process.env.VERBOSE) {... | [
"function",
"(",
"urlPath",
",",
"outStream",
",",
"callback",
")",
"{",
"needle",
".",
"get",
"(",
"`",
"${",
"urlPath",
"}",
"`",
",",
"{",
"follow_max",
":",
"5",
",",
"headers",
":",
"{",
"'User-Agent'",
":",
"'nodejs-client'",
"}",
"}",
",",
"("... | Downloads an archive usually zip or tar.gz from a URL which comes from the GitHub
release API.
@param {String} urlPath URL where to download the archive
@param {Stream} writeable output stream to save the archive
@param {Function} callback Callback (err)
@return {void} | [
"Downloads",
"an",
"archive",
"usually",
"zip",
"or",
"tar",
".",
"gz",
"from",
"a",
"URL",
"which",
"comes",
"from",
"the",
"GitHub",
"release",
"API",
"."
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/bin/installer.js#L91-L108 | |
6,412 | deepstreamIO/deepstream.io | bin/installer.js | function (directory) {
try {
const content = fs.readFileSync(path.join(directory, CONFIG_EXAMPLE_FILE), 'utf8')
if (process.env.VERBOSE) {
console.log('You need to configure the connector in your deepstream configuration file')
}
if (!process.env.QUIET) {
console.log(`Example configuration... | javascript | function (directory) {
try {
const content = fs.readFileSync(path.join(directory, CONFIG_EXAMPLE_FILE), 'utf8')
if (process.env.VERBOSE) {
console.log('You need to configure the connector in your deepstream configuration file')
}
if (!process.env.QUIET) {
console.log(`Example configuration... | [
"function",
"(",
"directory",
")",
"{",
"try",
"{",
"const",
"content",
"=",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"join",
"(",
"directory",
",",
"CONFIG_EXAMPLE_FILE",
")",
",",
"'utf8'",
")",
"if",
"(",
"process",
".",
"env",
".",
"VERBOSE",
"... | Prints out the config snippet of a extract connector to the stdout.
Output is indented and grey colored.
@param {String} directory where to lookup for CONFIG_EXAMPLE_FILE
@return {void} | [
"Prints",
"out",
"the",
"config",
"snippet",
"of",
"a",
"extract",
"connector",
"to",
"the",
"stdout",
".",
"Output",
"is",
"indented",
"and",
"grey",
"colored",
"."
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/bin/installer.js#L193-L207 | |
6,413 | deepstreamIO/deepstream.io | src/config/file-utils.js | resolvePrefixAndFile | function resolvePrefixAndFile (nonAbsoluteFilePath, prefix) {
// prefix is not absolute
if (path.parse(prefix).root === '') {
return path.resolve(process.cwd(), prefix, nonAbsoluteFilePath)
}
// prefix is absolute
return path.resolve(prefix, nonAbsoluteFilePath)
} | javascript | function resolvePrefixAndFile (nonAbsoluteFilePath, prefix) {
// prefix is not absolute
if (path.parse(prefix).root === '') {
return path.resolve(process.cwd(), prefix, nonAbsoluteFilePath)
}
// prefix is absolute
return path.resolve(prefix, nonAbsoluteFilePath)
} | [
"function",
"resolvePrefixAndFile",
"(",
"nonAbsoluteFilePath",
",",
"prefix",
")",
"{",
"// prefix is not absolute",
"if",
"(",
"path",
".",
"parse",
"(",
"prefix",
")",
".",
"root",
"===",
"''",
")",
"{",
"return",
"path",
".",
"resolve",
"(",
"process",
"... | Append the prefix to the current working directory,
or use it as an absolute path
@param {String} nonAbsoluteFilePath
@param {String} prefix
@private
@returns {String} resolvedPath | [
"Append",
"the",
"prefix",
"to",
"the",
"current",
"working",
"directory",
"or",
"use",
"it",
"as",
"an",
"absolute",
"path"
] | 247aea5e49a94f57f72fbac8e2f4dc0cdbbded18 | https://github.com/deepstreamIO/deepstream.io/blob/247aea5e49a94f57f72fbac8e2f4dc0cdbbded18/src/config/file-utils.js#L100-L108 |
6,414 | patternfly/patternfly-react | scripts/incrementalBuild.js | getInvalidPackages | async function getInvalidPackages() {
const packages = (await new Project(__dirname).getPackages())
.filter(p => p.scripts.build) // Only packages that have a build target
.filter(p => isPf3
? p.location.indexOf('patternfly-3') !== -1 || commonPackages.indexOf(p.name) !== -1
: true) // Based off a... | javascript | async function getInvalidPackages() {
const packages = (await new Project(__dirname).getPackages())
.filter(p => p.scripts.build) // Only packages that have a build target
.filter(p => isPf3
? p.location.indexOf('patternfly-3') !== -1 || commonPackages.indexOf(p.name) !== -1
: true) // Based off a... | [
"async",
"function",
"getInvalidPackages",
"(",
")",
"{",
"const",
"packages",
"=",
"(",
"await",
"new",
"Project",
"(",
"__dirname",
")",
".",
"getPackages",
"(",
")",
")",
".",
"filter",
"(",
"p",
"=>",
"p",
".",
"scripts",
".",
"build",
")",
"// Onl... | These are packages we need to rebuild | [
"These",
"are",
"packages",
"we",
"need",
"to",
"rebuild"
] | 82f8002e30b41888d4f22daffe170f0f733ec591 | https://github.com/patternfly/patternfly-react/blob/82f8002e30b41888d4f22daffe170f0f733ec591/scripts/incrementalBuild.js#L31-L51 |
6,415 | dimsemenov/Magnific-Popup | src/js/core.js | function() {
if(!mfp.isOpen) return;
_mfpTrigger(BEFORE_CLOSE_EVENT);
mfp.isOpen = false;
// for CSS3 animation
if(mfp.st.removalDelay && !mfp.isLowIE && mfp.supportsTransition ) {
mfp._addClassToMFP(REMOVING_CLASS);
setTimeout(function() {
mfp._close();
}, mfp.st.removalDelay);
} else {
m... | javascript | function() {
if(!mfp.isOpen) return;
_mfpTrigger(BEFORE_CLOSE_EVENT);
mfp.isOpen = false;
// for CSS3 animation
if(mfp.st.removalDelay && !mfp.isLowIE && mfp.supportsTransition ) {
mfp._addClassToMFP(REMOVING_CLASS);
setTimeout(function() {
mfp._close();
}, mfp.st.removalDelay);
} else {
m... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"mfp",
".",
"isOpen",
")",
"return",
";",
"_mfpTrigger",
"(",
"BEFORE_CLOSE_EVENT",
")",
";",
"mfp",
".",
"isOpen",
"=",
"false",
";",
"// for CSS3 animation",
"if",
"(",
"mfp",
".",
"st",
".",
"removalDelay",
... | Closes the popup | [
"Closes",
"the",
"popup"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/src/js/core.js#L370-L384 | |
6,416 | dimsemenov/Magnific-Popup | src/js/core.js | function() {
var item = mfp.items[mfp.index];
// Detach and perform modifications
mfp.contentContainer.detach();
if(mfp.content)
mfp.content.detach();
if(!item.parsed) {
item = mfp.parseEl( mfp.index );
}
var type = item.type;
_mfpTrigger('BeforeChange', [mfp.currItem ? mfp.currItem.type : ''... | javascript | function() {
var item = mfp.items[mfp.index];
// Detach and perform modifications
mfp.contentContainer.detach();
if(mfp.content)
mfp.content.detach();
if(!item.parsed) {
item = mfp.parseEl( mfp.index );
}
var type = item.type;
_mfpTrigger('BeforeChange', [mfp.currItem ? mfp.currItem.type : ''... | [
"function",
"(",
")",
"{",
"var",
"item",
"=",
"mfp",
".",
"items",
"[",
"mfp",
".",
"index",
"]",
";",
"// Detach and perform modifications",
"mfp",
".",
"contentContainer",
".",
"detach",
"(",
")",
";",
"if",
"(",
"mfp",
".",
"content",
")",
"mfp",
"... | Set content of popup based on current index | [
"Set",
"content",
"of",
"popup",
"based",
"on",
"current",
"index"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/src/js/core.js#L464-L515 | |
6,417 | dimsemenov/Magnific-Popup | src/js/core.js | function(newContent, type) {
mfp.content = newContent;
if(newContent) {
if(mfp.st.showCloseBtn && mfp.st.closeBtnInside &&
mfp.currTemplate[type] === true) {
// if there is no markup, we just append close button element inside
if(!mfp.content.find('.mfp-close').length) {
mfp.content.append(_get... | javascript | function(newContent, type) {
mfp.content = newContent;
if(newContent) {
if(mfp.st.showCloseBtn && mfp.st.closeBtnInside &&
mfp.currTemplate[type] === true) {
// if there is no markup, we just append close button element inside
if(!mfp.content.find('.mfp-close').length) {
mfp.content.append(_get... | [
"function",
"(",
"newContent",
",",
"type",
")",
"{",
"mfp",
".",
"content",
"=",
"newContent",
";",
"if",
"(",
"newContent",
")",
"{",
"if",
"(",
"mfp",
".",
"st",
".",
"showCloseBtn",
"&&",
"mfp",
".",
"st",
".",
"closeBtnInside",
"&&",
"mfp",
".",... | Set HTML content of popup | [
"Set",
"HTML",
"content",
"of",
"popup"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/src/js/core.js#L521-L542 | |
6,418 | dimsemenov/Magnific-Popup | src/js/core.js | function(index) {
var item = mfp.items[index],
type;
if(item.tagName) {
item = { el: $(item) };
} else {
type = item.type;
item = { data: item, src: item.src };
}
if(item.el) {
var types = mfp.types;
// check for 'mfp-TYPE' class
for(var i = 0; i < types.length; i++) {
if( item.el.... | javascript | function(index) {
var item = mfp.items[index],
type;
if(item.tagName) {
item = { el: $(item) };
} else {
type = item.type;
item = { data: item, src: item.src };
}
if(item.el) {
var types = mfp.types;
// check for 'mfp-TYPE' class
for(var i = 0; i < types.length; i++) {
if( item.el.... | [
"function",
"(",
"index",
")",
"{",
"var",
"item",
"=",
"mfp",
".",
"items",
"[",
"index",
"]",
",",
"type",
";",
"if",
"(",
"item",
".",
"tagName",
")",
"{",
"item",
"=",
"{",
"el",
":",
"$",
"(",
"item",
")",
"}",
";",
"}",
"else",
"{",
"... | Creates Magnific Popup data object based on given data
@param {int} index Index of item to parse | [
"Creates",
"Magnific",
"Popup",
"data",
"object",
"based",
"on",
"given",
"data"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/src/js/core.js#L549-L584 | |
6,419 | dimsemenov/Magnific-Popup | src/js/core.js | function(el, options) {
var eHandler = function(e) {
e.mfpEl = this;
mfp._openClick(e, el, options);
};
if(!options) {
options = {};
}
var eName = 'click.magnificPopup';
options.mainEl = el;
if(options.items) {
options.isObj = true;
el.off(eName).on(eName, eHandler);
} else {
option... | javascript | function(el, options) {
var eHandler = function(e) {
e.mfpEl = this;
mfp._openClick(e, el, options);
};
if(!options) {
options = {};
}
var eName = 'click.magnificPopup';
options.mainEl = el;
if(options.items) {
options.isObj = true;
el.off(eName).on(eName, eHandler);
} else {
option... | [
"function",
"(",
"el",
",",
"options",
")",
"{",
"var",
"eHandler",
"=",
"function",
"(",
"e",
")",
"{",
"e",
".",
"mfpEl",
"=",
"this",
";",
"mfp",
".",
"_openClick",
"(",
"e",
",",
"el",
",",
"options",
")",
";",
"}",
";",
"if",
"(",
"!",
"... | Initializes single popup or a group of popups | [
"Initializes",
"single",
"popup",
"or",
"a",
"group",
"of",
"popups"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/src/js/core.js#L590-L615 | |
6,420 | dimsemenov/Magnific-Popup | src/js/core.js | function(status, text) {
if(mfp.preloader) {
if(_prevStatus !== status) {
mfp.container.removeClass('mfp-s-'+_prevStatus);
}
if(!text && status === 'loading') {
text = mfp.st.tLoading;
}
var data = {
status: status,
text: text
};
// allows to modify status
_mfpTrigger('Updat... | javascript | function(status, text) {
if(mfp.preloader) {
if(_prevStatus !== status) {
mfp.container.removeClass('mfp-s-'+_prevStatus);
}
if(!text && status === 'loading') {
text = mfp.st.tLoading;
}
var data = {
status: status,
text: text
};
// allows to modify status
_mfpTrigger('Updat... | [
"function",
"(",
"status",
",",
"text",
")",
"{",
"if",
"(",
"mfp",
".",
"preloader",
")",
"{",
"if",
"(",
"_prevStatus",
"!==",
"status",
")",
"{",
"mfp",
".",
"container",
".",
"removeClass",
"(",
"'mfp-s-'",
"+",
"_prevStatus",
")",
";",
"}",
"if"... | Updates text on preloader | [
"Updates",
"text",
"on",
"preloader"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/src/js/core.js#L658-L688 | |
6,421 | dimsemenov/Magnific-Popup | website/third-party-libs/zepto.js | deserializeValue | function deserializeValue(value) {
var num
try {
return value ?
value == "true" ||
( value == "false" ? false :
value == "null" ? null :
!isNaN(num = Number(value)) ? num :
/^[\[\{]/.test(value) ? $.parseJSON(value) :
value )
: value
} ca... | javascript | function deserializeValue(value) {
var num
try {
return value ?
value == "true" ||
( value == "false" ? false :
value == "null" ? null :
!isNaN(num = Number(value)) ? num :
/^[\[\{]/.test(value) ? $.parseJSON(value) :
value )
: value
} ca... | [
"function",
"deserializeValue",
"(",
"value",
")",
"{",
"var",
"num",
"try",
"{",
"return",
"value",
"?",
"value",
"==",
"\"true\"",
"||",
"(",
"value",
"==",
"\"false\"",
"?",
"false",
":",
"value",
"==",
"\"null\"",
"?",
"null",
":",
"!",
"isNaN",
"(... | "true" => true "false" => false "null" => null "42" => 42 "42.5" => 42.5 JSON => parse if valid String => self | [
"true",
"=",
">",
"true",
"false",
"=",
">",
"false",
"null",
"=",
">",
"null",
"42",
"=",
">",
"42",
"42",
".",
"5",
"=",
">",
"42",
".",
"5",
"JSON",
"=",
">",
"parse",
"if",
"valid",
"String",
"=",
">",
"self"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/website/third-party-libs/zepto.js#L289-L303 |
6,422 | dimsemenov/Magnific-Popup | website/third-party-libs/zepto.js | fix | function fix(event) {
if (!('defaultPrevented' in event)) {
event.defaultPrevented = false
var prevent = event.preventDefault
event.preventDefault = function() {
this.defaultPrevented = true
prevent.call(this)
}
}
} | javascript | function fix(event) {
if (!('defaultPrevented' in event)) {
event.defaultPrevented = false
var prevent = event.preventDefault
event.preventDefault = function() {
this.defaultPrevented = true
prevent.call(this)
}
}
} | [
"function",
"fix",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"(",
"'defaultPrevented'",
"in",
"event",
")",
")",
"{",
"event",
".",
"defaultPrevented",
"=",
"false",
"var",
"prevent",
"=",
"event",
".",
"preventDefault",
"event",
".",
"preventDefault",
"=",
... | emulates the 'defaultPrevented' property for browsers that have none | [
"emulates",
"the",
"defaultPrevented",
"property",
"for",
"browsers",
"that",
"have",
"none"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/website/third-party-libs/zepto.js#L1012-L1021 |
6,423 | dimsemenov/Magnific-Popup | src/js/image.js | function(item) {
var counter = 0,
img = item.img[0],
mfpSetInterval = function(delay) {
if(_imgInterval) {
clearInterval(_imgInterval);
}
// decelerating interval that checks for size of an image
_imgInterval = setInterval(function() {
if(img.naturalWidth > 0) {
mfp._... | javascript | function(item) {
var counter = 0,
img = item.img[0],
mfpSetInterval = function(delay) {
if(_imgInterval) {
clearInterval(_imgInterval);
}
// decelerating interval that checks for size of an image
_imgInterval = setInterval(function() {
if(img.naturalWidth > 0) {
mfp._... | [
"function",
"(",
"item",
")",
"{",
"var",
"counter",
"=",
"0",
",",
"img",
"=",
"item",
".",
"img",
"[",
"0",
"]",
",",
"mfpSetInterval",
"=",
"function",
"(",
"delay",
")",
"{",
"if",
"(",
"_imgInterval",
")",
"{",
"clearInterval",
"(",
"_imgInterva... | Function that loops until the image has size to display elements that rely on it asap | [
"Function",
"that",
"loops",
"until",
"the",
"image",
"has",
"size",
"to",
"display",
"elements",
"that",
"rely",
"on",
"it",
"asap"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/src/js/image.js#L103-L135 | |
6,424 | inorganik/countUp.js | demo.js | createCountUp | function createCountUp() {
establishOptionsFromInputs();
demo = new CountUp('myTargetElement', endVal, options);
if (!demo.error) {
errorSection.style.display = 'none';
if (input('useOnComplete').checked) {
demo.start(methodToCallOnComplete);
}
else {
demo.start();
... | javascript | function createCountUp() {
establishOptionsFromInputs();
demo = new CountUp('myTargetElement', endVal, options);
if (!demo.error) {
errorSection.style.display = 'none';
if (input('useOnComplete').checked) {
demo.start(methodToCallOnComplete);
}
else {
demo.start();
... | [
"function",
"createCountUp",
"(",
")",
"{",
"establishOptionsFromInputs",
"(",
")",
";",
"demo",
"=",
"new",
"CountUp",
"(",
"'myTargetElement'",
",",
"endVal",
",",
"options",
")",
";",
"if",
"(",
"!",
"demo",
".",
"error",
")",
"{",
"errorSection",
".",
... | COUNTUP AND CODE VISUALIZER | [
"COUNTUP",
"AND",
"CODE",
"VISUALIZER"
] | 29ba37c1f4f02a00ef19c9abbdc58d1b610f7d38 | https://github.com/inorganik/countUp.js/blob/29ba37c1f4f02a00ef19c9abbdc58d1b610f7d38/demo.js#L108-L126 |
6,425 | mongodb/node-mongodb-native | lib/change_stream.js | function(self) {
if (self.resumeToken) {
self.options.resumeAfter = self.resumeToken;
}
var changeStreamCursor = buildChangeStreamAggregationCommand(self);
/**
* Fired for each new matching change in the specified namespace. Attaching a `change`
* event listener to a Change Stream will switch the st... | javascript | function(self) {
if (self.resumeToken) {
self.options.resumeAfter = self.resumeToken;
}
var changeStreamCursor = buildChangeStreamAggregationCommand(self);
/**
* Fired for each new matching change in the specified namespace. Attaching a `change`
* event listener to a Change Stream will switch the st... | [
"function",
"(",
"self",
")",
"{",
"if",
"(",
"self",
".",
"resumeToken",
")",
"{",
"self",
".",
"options",
".",
"resumeAfter",
"=",
"self",
".",
"resumeToken",
";",
"}",
"var",
"changeStreamCursor",
"=",
"buildChangeStreamAggregationCommand",
"(",
"self",
"... | Create a new change stream cursor based on self's configuration | [
"Create",
"a",
"new",
"change",
"stream",
"cursor",
"based",
"on",
"self",
"s",
"configuration"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/change_stream.js#L224-L283 | |
6,426 | mongodb/node-mongodb-native | lib/gridfs-stream/index.js | GridFSBucket | function GridFSBucket(db, options) {
Emitter.apply(this);
this.setMaxListeners(0);
if (options && typeof options === 'object') {
options = shallowClone(options);
var keys = Object.keys(DEFAULT_GRIDFS_BUCKET_OPTIONS);
for (var i = 0; i < keys.length; ++i) {
if (!options[keys[i]]) {
optio... | javascript | function GridFSBucket(db, options) {
Emitter.apply(this);
this.setMaxListeners(0);
if (options && typeof options === 'object') {
options = shallowClone(options);
var keys = Object.keys(DEFAULT_GRIDFS_BUCKET_OPTIONS);
for (var i = 0; i < keys.length; ++i) {
if (!options[keys[i]]) {
optio... | [
"function",
"GridFSBucket",
"(",
"db",
",",
"options",
")",
"{",
"Emitter",
".",
"apply",
"(",
"this",
")",
";",
"this",
".",
"setMaxListeners",
"(",
"0",
")",
";",
"if",
"(",
"options",
"&&",
"typeof",
"options",
"===",
"'object'",
")",
"{",
"options"... | Constructor for a streaming GridFS interface
@class
@param {Db} db A db handle
@param {object} [options] Optional settings.
@param {string} [options.bucketName="fs"] The 'files' and 'chunks' collections will be prefixed with the bucket name followed by a dot.
@param {number} [options.chunkSizeBytes=255 * 1024] Number o... | [
"Constructor",
"for",
"a",
"streaming",
"GridFS",
"interface"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs-stream/index.js#L31-L56 |
6,427 | mongodb/node-mongodb-native | lib/operations/db_ops.js | collections | function collections(db, options, callback) {
let Collection = loadCollection();
options = Object.assign({}, options, { nameOnly: true });
// Let's get the collection names
db.listCollections({}, options).toArray((err, documents) => {
if (err != null) return handleCallback(callback, err, null);
// Filt... | javascript | function collections(db, options, callback) {
let Collection = loadCollection();
options = Object.assign({}, options, { nameOnly: true });
// Let's get the collection names
db.listCollections({}, options).toArray((err, documents) => {
if (err != null) return handleCallback(callback, err, null);
// Filt... | [
"function",
"collections",
"(",
"db",
",",
"options",
",",
"callback",
")",
"{",
"let",
"Collection",
"=",
"loadCollection",
"(",
")",
";",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
",",
"{",
"nameOnly",
":",
"true",
"}",
... | Fetch all collections for the current db.
@method
@param {Db} db The Db instance on which to fetch collections.
@param {object} [options] Optional settings. See Db.prototype.collections for a list of options.
@param {Db~collectionsResultCallback} [callback] The results callback | [
"Fetch",
"all",
"collections",
"for",
"the",
"current",
"db",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L149-L177 |
6,428 | mongodb/node-mongodb-native | lib/operations/db_ops.js | createIndex | function createIndex(db, name, fieldOrSpec, options, callback) {
// Get the write concern options
let finalOptions = Object.assign({}, { readPreference: ReadPreference.PRIMARY }, options);
finalOptions = applyWriteConcern(finalOptions, { db }, options);
// Ensure we have a callback
if (finalOptions.writeConc... | javascript | function createIndex(db, name, fieldOrSpec, options, callback) {
// Get the write concern options
let finalOptions = Object.assign({}, { readPreference: ReadPreference.PRIMARY }, options);
finalOptions = applyWriteConcern(finalOptions, { db }, options);
// Ensure we have a callback
if (finalOptions.writeConc... | [
"function",
"createIndex",
"(",
"db",
",",
"name",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
"{",
"// Get the write concern options",
"let",
"finalOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"{",
"readPreference",
":",
"ReadPref... | Creates an index on the db and collection.
@method
@param {Db} db The Db instance on which to create an index.
@param {string} name Name of the collection to create the index on.
@param {(string|object)} fieldOrSpec Defines the index.
@param {object} [options] Optional settings. See Db.prototype.createIndex for a list ... | [
"Creates",
"an",
"index",
"on",
"the",
"db",
"and",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L274-L334 |
6,429 | mongodb/node-mongodb-native | lib/operations/db_ops.js | createListener | function createListener(db, e, object) {
function listener(err) {
if (object.listeners(e).length > 0) {
object.emit(e, err, db);
// Emit on all associated db's if available
for (let i = 0; i < db.s.children.length; i++) {
db.s.children[i].emit(e, err, db.s.children[i]);
}
}
... | javascript | function createListener(db, e, object) {
function listener(err) {
if (object.listeners(e).length > 0) {
object.emit(e, err, db);
// Emit on all associated db's if available
for (let i = 0; i < db.s.children.length; i++) {
db.s.children[i].emit(e, err, db.s.children[i]);
}
}
... | [
"function",
"createListener",
"(",
"db",
",",
"e",
",",
"object",
")",
"{",
"function",
"listener",
"(",
"err",
")",
"{",
"if",
"(",
"object",
".",
"listeners",
"(",
"e",
")",
".",
"length",
">",
"0",
")",
"{",
"object",
".",
"emit",
"(",
"e",
",... | Add listeners to topology | [
"Add",
"listeners",
"to",
"topology"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L337-L349 |
6,430 | mongodb/node-mongodb-native | lib/operations/db_ops.js | dropCollection | function dropCollection(db, name, options, callback) {
executeCommand(db, name, options, (err, result) => {
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed()) {
return callback(new MongoError('topology was destroyed'));
}
if (err) return handleCallback(ca... | javascript | function dropCollection(db, name, options, callback) {
executeCommand(db, name, options, (err, result) => {
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed()) {
return callback(new MongoError('topology was destroyed'));
}
if (err) return handleCallback(ca... | [
"function",
"dropCollection",
"(",
"db",
",",
"name",
",",
"options",
",",
"callback",
")",
"{",
"executeCommand",
"(",
"db",
",",
"name",
",",
"options",
",",
"(",
"err",
",",
"result",
")",
"=>",
"{",
"// Did the user destroy the topology",
"if",
"(",
"d... | Drop a collection from the database, removing it permanently. New accesses will create a new collection.
@method
@param {Db} db The Db instance on which to drop the collection.
@param {string} name Name of collection to drop
@param {Object} [options] Optional settings. See Db.prototype.dropCollection for a list of opt... | [
"Drop",
"a",
"collection",
"from",
"the",
"database",
"removing",
"it",
"permanently",
".",
"New",
"accesses",
"will",
"create",
"a",
"new",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L360-L371 |
6,431 | mongodb/node-mongodb-native | lib/operations/db_ops.js | dropDatabase | function dropDatabase(db, cmd, options, callback) {
executeCommand(db, cmd, options, (err, result) => {
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed()) {
return callback(new MongoError('topology was destroyed'));
}
if (callback == null) return;
if ... | javascript | function dropDatabase(db, cmd, options, callback) {
executeCommand(db, cmd, options, (err, result) => {
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed()) {
return callback(new MongoError('topology was destroyed'));
}
if (callback == null) return;
if ... | [
"function",
"dropDatabase",
"(",
"db",
",",
"cmd",
",",
"options",
",",
"callback",
")",
"{",
"executeCommand",
"(",
"db",
",",
"cmd",
",",
"options",
",",
"(",
"err",
",",
"result",
")",
"=>",
"{",
"// Did the user destroy the topology",
"if",
"(",
"db",
... | Drop a database, removing it permanently from the server.
@method
@param {Db} db The Db instance to drop.
@param {Object} cmd The command document.
@param {Object} [options] Optional settings. See Db.prototype.dropDatabase for a list of options.
@param {Db~resultCallback} [callback] The results callback | [
"Drop",
"a",
"database",
"removing",
"it",
"permanently",
"from",
"the",
"server",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L382-L393 |
6,432 | mongodb/node-mongodb-native | lib/operations/db_ops.js | ensureIndex | function ensureIndex(db, name, fieldOrSpec, options, callback) {
// Get the write concern options
const finalOptions = applyWriteConcern({}, { db }, options);
// Create command
const selector = createCreateIndexCommand(db, name, fieldOrSpec, options);
const index_name = selector.name;
// Did the user destr... | javascript | function ensureIndex(db, name, fieldOrSpec, options, callback) {
// Get the write concern options
const finalOptions = applyWriteConcern({}, { db }, options);
// Create command
const selector = createCreateIndexCommand(db, name, fieldOrSpec, options);
const index_name = selector.name;
// Did the user destr... | [
"function",
"ensureIndex",
"(",
"db",
",",
"name",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
"{",
"// Get the write concern options",
"const",
"finalOptions",
"=",
"applyWriteConcern",
"(",
"{",
"}",
",",
"{",
"db",
"}",
",",
"options",
")",
... | Ensures that an index exists. If it does not, creates it.
@method
@param {Db} db The Db instance on which to ensure the index.
@param {string} name The index name
@param {(string|object)} fieldOrSpec Defines the index.
@param {object} [options] Optional settings. See Db.prototype.ensureIndex for a list of options.
@pa... | [
"Ensures",
"that",
"an",
"index",
"exists",
".",
"If",
"it",
"does",
"not",
"creates",
"it",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L405-L429 |
6,433 | mongodb/node-mongodb-native | lib/operations/db_ops.js | evaluate | function evaluate(db, code, parameters, options, callback) {
let finalCode = code;
let finalParameters = [];
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed())
return callback(new MongoError('topology was destroyed'));
// If not a code object translate to one
if... | javascript | function evaluate(db, code, parameters, options, callback) {
let finalCode = code;
let finalParameters = [];
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed())
return callback(new MongoError('topology was destroyed'));
// If not a code object translate to one
if... | [
"function",
"evaluate",
"(",
"db",
",",
"code",
",",
"parameters",
",",
"options",
",",
"callback",
")",
"{",
"let",
"finalCode",
"=",
"code",
";",
"let",
"finalParameters",
"=",
"[",
"]",
";",
"// Did the user destroy the topology",
"if",
"(",
"db",
".",
... | Evaluate JavaScript on the server
@method
@param {Db} db The Db instance.
@param {Code} code JavaScript to execute on server.
@param {(object|array)} parameters The parameters for the call.
@param {object} [options] Optional settings. See Db.prototype.eval for a list of options.
@param {Db~resultCallback} [callback] T... | [
"Evaluate",
"JavaScript",
"on",
"the",
"server"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L442-L481 |
6,434 | mongodb/node-mongodb-native | lib/operations/db_ops.js | executeDbAdminCommand | function executeDbAdminCommand(db, command, options, callback) {
db.s.topology.command('admin.$cmd', command, options, (err, result) => {
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed()) {
return callback(new MongoError('topology was destroyed'));
}
if ... | javascript | function executeDbAdminCommand(db, command, options, callback) {
db.s.topology.command('admin.$cmd', command, options, (err, result) => {
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed()) {
return callback(new MongoError('topology was destroyed'));
}
if ... | [
"function",
"executeDbAdminCommand",
"(",
"db",
",",
"command",
",",
"options",
",",
"callback",
")",
"{",
"db",
".",
"s",
".",
"topology",
".",
"command",
"(",
"'admin.$cmd'",
",",
"command",
",",
"options",
",",
"(",
"err",
",",
"result",
")",
"=>",
... | Runs a command on the database as admin.
@method
@param {Db} db The Db instance on which to execute the command.
@param {object} command The command hash
@param {object} [options] Optional settings. See Db.prototype.executeDbAdminCommand for a list of options.
@param {Db~resultCallback} [callback] The command result c... | [
"Runs",
"a",
"command",
"on",
"the",
"database",
"as",
"admin",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L529-L539 |
6,435 | mongodb/node-mongodb-native | lib/operations/db_ops.js | indexInformation | function indexInformation(db, name, options, callback) {
// If we specified full information
const full = options['full'] == null ? false : options['full'];
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed())
return callback(new MongoError('topology was destroyed'));
... | javascript | function indexInformation(db, name, options, callback) {
// If we specified full information
const full = options['full'] == null ? false : options['full'];
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed())
return callback(new MongoError('topology was destroyed'));
... | [
"function",
"indexInformation",
"(",
"db",
",",
"name",
",",
"options",
",",
"callback",
")",
"{",
"// If we specified full information",
"const",
"full",
"=",
"options",
"[",
"'full'",
"]",
"==",
"null",
"?",
"false",
":",
"options",
"[",
"'full'",
"]",
";"... | Retrieves this collections index info.
@method
@param {Db} db The Db instance on which to retrieve the index info.
@param {string} name The name of the collection.
@param {object} [options] Optional settings. See Db.prototype.indexInformation for a list of options.
@param {Db~resultCallback} [callback] The command res... | [
"Retrieves",
"this",
"collections",
"index",
"info",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L550-L584 |
6,436 | mongodb/node-mongodb-native | lib/operations/db_ops.js | processResults | function processResults(indexes) {
// Contains all the information
let info = {};
// Process all the indexes
for (let i = 0; i < indexes.length; i++) {
const index = indexes[i];
// Let's unpack the object
info[index.name] = [];
for (let name in index.key) {
info[index.nam... | javascript | function processResults(indexes) {
// Contains all the information
let info = {};
// Process all the indexes
for (let i = 0; i < indexes.length; i++) {
const index = indexes[i];
// Let's unpack the object
info[index.name] = [];
for (let name in index.key) {
info[index.nam... | [
"function",
"processResults",
"(",
"indexes",
")",
"{",
"// Contains all the information",
"let",
"info",
"=",
"{",
"}",
";",
"// Process all the indexes",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"indexes",
".",
"length",
";",
"i",
"++",
")",
"{",... | Process all the results from the index command and collection | [
"Process",
"all",
"the",
"results",
"from",
"the",
"index",
"command",
"and",
"collection"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L558-L572 |
6,437 | mongodb/node-mongodb-native | lib/operations/db_ops.js | listCollectionsTransforms | function listCollectionsTransforms(databaseName) {
const matching = `${databaseName}.`;
return {
doc: doc => {
const index = doc.name.indexOf(matching);
// Remove database name if available
if (doc.name && index === 0) {
doc.name = doc.name.substr(index + matching.length);
}
... | javascript | function listCollectionsTransforms(databaseName) {
const matching = `${databaseName}.`;
return {
doc: doc => {
const index = doc.name.indexOf(matching);
// Remove database name if available
if (doc.name && index === 0) {
doc.name = doc.name.substr(index + matching.length);
}
... | [
"function",
"listCollectionsTransforms",
"(",
"databaseName",
")",
"{",
"const",
"matching",
"=",
"`",
"${",
"databaseName",
"}",
"`",
";",
"return",
"{",
"doc",
":",
"doc",
"=>",
"{",
"const",
"index",
"=",
"doc",
".",
"name",
".",
"indexOf",
"(",
"matc... | Transformation methods for cursor results | [
"Transformation",
"methods",
"for",
"cursor",
"results"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L587-L601 |
6,438 | mongodb/node-mongodb-native | lib/operations/db_ops.js | profilingInfo | function profilingInfo(db, options, callback) {
try {
db
.collection('system.profile')
.find({}, options)
.toArray(callback);
} catch (err) {
return callback(err, null);
}
} | javascript | function profilingInfo(db, options, callback) {
try {
db
.collection('system.profile')
.find({}, options)
.toArray(callback);
} catch (err) {
return callback(err, null);
}
} | [
"function",
"profilingInfo",
"(",
"db",
",",
"options",
",",
"callback",
")",
"{",
"try",
"{",
"db",
".",
"collection",
"(",
"'system.profile'",
")",
".",
"find",
"(",
"{",
"}",
",",
"options",
")",
".",
"toArray",
"(",
"callback",
")",
";",
"}",
"ca... | Retrieve the current profiling information for MongoDB
@method
@param {Db} db The Db instance on which to retrieve the profiling info.
@param {Object} [options] Optional settings. See Db.protoype.profilingInfo for a list of options.
@param {Db~resultCallback} [callback] The command result callback.
@deprecated Query t... | [
"Retrieve",
"the",
"current",
"profiling",
"information",
"for",
"MongoDB"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L612-L621 |
6,439 | mongodb/node-mongodb-native | lib/operations/db_ops.js | profilingLevel | function profilingLevel(db, options, callback) {
executeCommand(db, { profile: -1 }, options, (err, doc) => {
if (err == null && doc.ok === 1) {
const was = doc.was;
if (was === 0) return callback(null, 'off');
if (was === 1) return callback(null, 'slow_only');
if (was === 2) return callba... | javascript | function profilingLevel(db, options, callback) {
executeCommand(db, { profile: -1 }, options, (err, doc) => {
if (err == null && doc.ok === 1) {
const was = doc.was;
if (was === 0) return callback(null, 'off');
if (was === 1) return callback(null, 'slow_only');
if (was === 2) return callba... | [
"function",
"profilingLevel",
"(",
"db",
",",
"options",
",",
"callback",
")",
"{",
"executeCommand",
"(",
"db",
",",
"{",
"profile",
":",
"-",
"1",
"}",
",",
"options",
",",
"(",
"err",
",",
"doc",
")",
"=>",
"{",
"if",
"(",
"err",
"==",
"null",
... | Retrieve the current profiling level for MongoDB
@method
@param {Db} db The Db instance on which to retrieve the profiling level.
@param {Object} [options] Optional settings. See Db.prototype.profilingLevel for a list of options.
@param {Db~resultCallback} [callback] The command result callback | [
"Retrieve",
"the",
"current",
"profiling",
"level",
"for",
"MongoDB"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L631-L643 |
6,440 | mongodb/node-mongodb-native | lib/operations/db_ops.js | removeUser | function removeUser(db, username, options, callback) {
let Db = loadDb();
// Attempt to execute command
executeAuthRemoveUserCommand(db, username, options, (err, result) => {
if (err && err.code === -5000) {
const finalOptions = applyWriteConcern(Object.assign({}, options), { db }, options);
// I... | javascript | function removeUser(db, username, options, callback) {
let Db = loadDb();
// Attempt to execute command
executeAuthRemoveUserCommand(db, username, options, (err, result) => {
if (err && err.code === -5000) {
const finalOptions = applyWriteConcern(Object.assign({}, options), { db }, options);
// I... | [
"function",
"removeUser",
"(",
"db",
",",
"username",
",",
"options",
",",
"callback",
")",
"{",
"let",
"Db",
"=",
"loadDb",
"(",
")",
";",
"// Attempt to execute command",
"executeAuthRemoveUserCommand",
"(",
"db",
",",
"username",
",",
"options",
",",
"(",
... | Remove a user from a database
@method
@param {Db} db The Db instance on which to remove the user.
@param {string} username The username.
@param {object} [options] Optional settings. See Db.prototype.removeUser for a list of options.
@param {Db~resultCallback} [callback] The command result callback | [
"Remove",
"a",
"user",
"from",
"a",
"database"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L654-L681 |
6,441 | mongodb/node-mongodb-native | lib/operations/db_ops.js | setProfilingLevel | function setProfilingLevel(db, level, options, callback) {
const command = {};
let profile = 0;
if (level === 'off') {
profile = 0;
} else if (level === 'slow_only') {
profile = 1;
} else if (level === 'all') {
profile = 2;
} else {
return callback(new Error('Error: illegal profiling level ... | javascript | function setProfilingLevel(db, level, options, callback) {
const command = {};
let profile = 0;
if (level === 'off') {
profile = 0;
} else if (level === 'slow_only') {
profile = 1;
} else if (level === 'all') {
profile = 2;
} else {
return callback(new Error('Error: illegal profiling level ... | [
"function",
"setProfilingLevel",
"(",
"db",
",",
"level",
",",
"options",
",",
"callback",
")",
"{",
"const",
"command",
"=",
"{",
"}",
";",
"let",
"profile",
"=",
"0",
";",
"if",
"(",
"level",
"===",
"'off'",
")",
"{",
"profile",
"=",
"0",
";",
"}... | Set the current profiling level of MongoDB
@method
@param {Db} db The Db instance on which to execute the command.
@param {string} level The new profiling level (off, slow_only, all).
@param {Object} [options] Optional settings. See Db.prototype.setProfilingLevel for a list of options.
@param {Db~resultCallback} [call... | [
"Set",
"the",
"current",
"profiling",
"level",
"of",
"MongoDB"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L692-L715 |
6,442 | mongodb/node-mongodb-native | lib/operations/db_ops.js | validateDatabaseName | function validateDatabaseName(databaseName) {
if (typeof databaseName !== 'string')
throw MongoError.create({ message: 'database name must be a string', driver: true });
if (databaseName.length === 0)
throw MongoError.create({ message: 'database name cannot be the empty string', driver: true });
if (datab... | javascript | function validateDatabaseName(databaseName) {
if (typeof databaseName !== 'string')
throw MongoError.create({ message: 'database name must be a string', driver: true });
if (databaseName.length === 0)
throw MongoError.create({ message: 'database name cannot be the empty string', driver: true });
if (datab... | [
"function",
"validateDatabaseName",
"(",
"databaseName",
")",
"{",
"if",
"(",
"typeof",
"databaseName",
"!==",
"'string'",
")",
"throw",
"MongoError",
".",
"create",
"(",
"{",
"message",
":",
"'database name must be a string'",
",",
"driver",
":",
"true",
"}",
"... | Validate the database name | [
"Validate",
"the",
"database",
"name"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L718-L733 |
6,443 | mongodb/node-mongodb-native | lib/operations/db_ops.js | createCreateIndexCommand | function createCreateIndexCommand(db, name, fieldOrSpec, options) {
const indexParameters = parseIndexOptions(fieldOrSpec);
const fieldHash = indexParameters.fieldHash;
// Generate the index name
const indexName = typeof options.name === 'string' ? options.name : indexParameters.name;
const selector = {
... | javascript | function createCreateIndexCommand(db, name, fieldOrSpec, options) {
const indexParameters = parseIndexOptions(fieldOrSpec);
const fieldHash = indexParameters.fieldHash;
// Generate the index name
const indexName = typeof options.name === 'string' ? options.name : indexParameters.name;
const selector = {
... | [
"function",
"createCreateIndexCommand",
"(",
"db",
",",
"name",
",",
"fieldOrSpec",
",",
"options",
")",
"{",
"const",
"indexParameters",
"=",
"parseIndexOptions",
"(",
"fieldOrSpec",
")",
";",
"const",
"fieldHash",
"=",
"indexParameters",
".",
"fieldHash",
";",
... | Create the command object for Db.prototype.createIndex.
@param {Db} db The Db instance on which to create the command.
@param {string} name Name of the collection to create the index on.
@param {(string|object)} fieldOrSpec Defines the index.
@param {Object} [options] Optional settings. See Db.prototype.createIndex fo... | [
"Create",
"the",
"command",
"object",
"for",
"Db",
".",
"prototype",
".",
"createIndex",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L744-L779 |
6,444 | mongodb/node-mongodb-native | lib/operations/db_ops.js | createIndexUsingCreateIndexes | function createIndexUsingCreateIndexes(db, name, fieldOrSpec, options, callback) {
// Build the index
const indexParameters = parseIndexOptions(fieldOrSpec);
// Generate the index name
const indexName = typeof options.name === 'string' ? options.name : indexParameters.name;
// Set up the index
const indexes... | javascript | function createIndexUsingCreateIndexes(db, name, fieldOrSpec, options, callback) {
// Build the index
const indexParameters = parseIndexOptions(fieldOrSpec);
// Generate the index name
const indexName = typeof options.name === 'string' ? options.name : indexParameters.name;
// Set up the index
const indexes... | [
"function",
"createIndexUsingCreateIndexes",
"(",
"db",
",",
"name",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
"{",
"// Build the index",
"const",
"indexParameters",
"=",
"parseIndexOptions",
"(",
"fieldOrSpec",
")",
";",
"// Generate the index name",
... | Create index using the createIndexes command.
@param {Db} db The Db instance on which to execute the command.
@param {string} name Name of the collection to create the index on.
@param {(string|object)} fieldOrSpec Defines the index.
@param {Object} [options] Optional settings. See Db.prototype.createIndex for a list ... | [
"Create",
"index",
"using",
"the",
"createIndexes",
"command",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L790-L839 |
6,445 | mongodb/node-mongodb-native | lib/operations/db_ops.js | executeAuthCreateUserCommand | function executeAuthCreateUserCommand(db, username, password, options, callback) {
// Special case where there is no password ($external users)
if (typeof username === 'string' && password != null && typeof password === 'object') {
options = password;
password = null;
}
// Unpack all options
if (type... | javascript | function executeAuthCreateUserCommand(db, username, password, options, callback) {
// Special case where there is no password ($external users)
if (typeof username === 'string' && password != null && typeof password === 'object') {
options = password;
password = null;
}
// Unpack all options
if (type... | [
"function",
"executeAuthCreateUserCommand",
"(",
"db",
",",
"username",
",",
"password",
",",
"options",
",",
"callback",
")",
"{",
"// Special case where there is no password ($external users)",
"if",
"(",
"typeof",
"username",
"===",
"'string'",
"&&",
"password",
"!="... | Run the createUser command.
@param {Db} db The Db instance on which to execute the command.
@param {string} username The username of the user to add.
@param {string} password The password of the user to add.
@param {object} [options] Optional settings. See Db.prototype.addUser for a list of options.
@param {Db~resultC... | [
"Run",
"the",
"createUser",
"command",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L850-L941 |
6,446 | mongodb/node-mongodb-native | lib/operations/db_ops.js | executeAuthRemoveUserCommand | function executeAuthRemoveUserCommand(db, username, options, callback) {
if (typeof options === 'function') (callback = options), (options = {});
options = options || {};
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed())
return callback(new MongoError('topology was ... | javascript | function executeAuthRemoveUserCommand(db, username, options, callback) {
if (typeof options === 'function') (callback = options), (options = {});
options = options || {};
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed())
return callback(new MongoError('topology was ... | [
"function",
"executeAuthRemoveUserCommand",
"(",
"db",
",",
"username",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"(",
"callback",
"=",
"options",
")",
",",
"(",
"options",
"=",
"{",
"}",
")",
";... | Run the dropUser command.
@param {Db} db The Db instance on which to execute the command.
@param {string} username The username of the user to remove.
@param {object} [options] Optional settings. See Db.prototype.removeUser for a list of options.
@param {Db~resultCallback} [callback] The command result callback | [
"Run",
"the",
"dropUser",
"command",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L951-L985 |
6,447 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | checkForAtomicOperators | function checkForAtomicOperators(update) {
const keys = Object.keys(update);
// same errors as the server would give for update doc lacking atomic operators
if (keys.length === 0) {
return toError('The update operation document must contain at least one atomic operator.');
}
if (keys[0][0] !== '$') {
... | javascript | function checkForAtomicOperators(update) {
const keys = Object.keys(update);
// same errors as the server would give for update doc lacking atomic operators
if (keys.length === 0) {
return toError('The update operation document must contain at least one atomic operator.');
}
if (keys[0][0] !== '$') {
... | [
"function",
"checkForAtomicOperators",
"(",
"update",
")",
"{",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"update",
")",
";",
"// same errors as the server would give for update doc lacking atomic operators",
"if",
"(",
"keys",
".",
"length",
"===",
"0",
")",
... | Check the update operation to ensure it has atomic operators. | [
"Check",
"the",
"update",
"operation",
"to",
"ensure",
"it",
"has",
"atomic",
"operators",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L167-L178 |
6,448 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | count | function count(coll, query, options, callback) {
if (typeof options === 'function') (callback = options), (options = {});
options = Object.assign({}, options);
options.collectionName = coll.s.name;
options.readPreference = resolveReadPreference(options, {
db: coll.s.db,
collection: coll
});
let cm... | javascript | function count(coll, query, options, callback) {
if (typeof options === 'function') (callback = options), (options = {});
options = Object.assign({}, options);
options.collectionName = coll.s.name;
options.readPreference = resolveReadPreference(options, {
db: coll.s.db,
collection: coll
});
let cm... | [
"function",
"count",
"(",
"coll",
",",
"query",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"(",
"callback",
"=",
"options",
")",
",",
"(",
"options",
"=",
"{",
"}",
")",
";",
"options",
"=",
... | Count the number of documents in the collection that match the query.
@method
@param {Collection} a Collection instance.
@param {object} query The query for the count.
@param {object} [options] Optional settings. See Collection.prototype.count for a list of options.
@param {Collection~countCallback} [callback] The com... | [
"Count",
"the",
"number",
"of",
"documents",
"in",
"the",
"collection",
"that",
"match",
"the",
"query",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L189-L210 |
6,449 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | buildCountCommand | function buildCountCommand(collectionOrCursor, query, options) {
const skip = options.skip;
const limit = options.limit;
let hint = options.hint;
const maxTimeMS = options.maxTimeMS;
query = query || {};
// Final query
const cmd = {
count: options.collectionName,
query: query
};
// check if ... | javascript | function buildCountCommand(collectionOrCursor, query, options) {
const skip = options.skip;
const limit = options.limit;
let hint = options.hint;
const maxTimeMS = options.maxTimeMS;
query = query || {};
// Final query
const cmd = {
count: options.collectionName,
query: query
};
// check if ... | [
"function",
"buildCountCommand",
"(",
"collectionOrCursor",
",",
"query",
",",
"options",
")",
"{",
"const",
"skip",
"=",
"options",
".",
"skip",
";",
"const",
"limit",
"=",
"options",
".",
"limit",
";",
"let",
"hint",
"=",
"options",
".",
"hint",
";",
"... | Build the count command.
@method
@param {collectionOrCursor} an instance of a collection or cursor
@param {object} query The query for the count.
@param {object} [options] Optional settings. See Collection.prototype.count and Cursor.prototype.count for a list of options. | [
"Build",
"the",
"count",
"command",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L247-L282 |
6,450 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | createIndex | function createIndex(coll, fieldOrSpec, options, callback) {
createIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback);
} | javascript | function createIndex(coll, fieldOrSpec, options, callback) {
createIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback);
} | [
"function",
"createIndex",
"(",
"coll",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
"{",
"createIndexDb",
"(",
"coll",
".",
"s",
".",
"db",
",",
"coll",
".",
"s",
".",
"name",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
";",... | Create an index on the db and collection.
@method
@param {Collection} a Collection instance.
@param {(string|object)} fieldOrSpec Defines the index.
@param {object} [options] Optional settings. See Collection.prototype.createIndex for a list of options.
@param {Collection~resultCallback} [callback] The command result ... | [
"Create",
"an",
"index",
"on",
"the",
"db",
"and",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L293-L295 |
6,451 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | deleteMany | function deleteMany(coll, filter, options, callback) {
options.single = false;
removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback));
} | javascript | function deleteMany(coll, filter, options, callback) {
options.single = false;
removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback));
} | [
"function",
"deleteMany",
"(",
"coll",
",",
"filter",
",",
"options",
",",
"callback",
")",
"{",
"options",
".",
"single",
"=",
"false",
";",
"removeDocuments",
"(",
"coll",
",",
"filter",
",",
"options",
",",
"(",
"err",
",",
"r",
")",
"=>",
"deleteCa... | Delete multiple documents from the collection.
@method
@param {Collection} a Collection instance.
@param {object} filter The Filter used to select the documents to remove
@param {object} [options] Optional settings. See Collection.prototype.deleteMany for a list of options.
@param {Collection~deleteWriteOpCallback} [c... | [
"Delete",
"multiple",
"documents",
"from",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L361-L365 |
6,452 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | deleteOne | function deleteOne(coll, filter, options, callback) {
options.single = true;
removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback));
} | javascript | function deleteOne(coll, filter, options, callback) {
options.single = true;
removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback));
} | [
"function",
"deleteOne",
"(",
"coll",
",",
"filter",
",",
"options",
",",
"callback",
")",
"{",
"options",
".",
"single",
"=",
"true",
";",
"removeDocuments",
"(",
"coll",
",",
"filter",
",",
"options",
",",
"(",
"err",
",",
"r",
")",
"=>",
"deleteCall... | Delete a single document from the collection.
@method
@param {Collection} a Collection instance.
@param {object} filter The Filter used to select the document to remove
@param {object} [options] Optional settings. See Collection.prototype.deleteOne for a list of options.
@param {Collection~deleteWriteOpCallback} [call... | [
"Delete",
"a",
"single",
"document",
"from",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L376-L379 |
6,453 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | distinct | function distinct(coll, key, query, options, callback) {
// maxTimeMS option
const maxTimeMS = options.maxTimeMS;
// Distinct command
const cmd = {
distinct: coll.s.name,
key: key,
query: query
};
options = Object.assign({}, options);
// Ensure we have the right read preference inheritance
... | javascript | function distinct(coll, key, query, options, callback) {
// maxTimeMS option
const maxTimeMS = options.maxTimeMS;
// Distinct command
const cmd = {
distinct: coll.s.name,
key: key,
query: query
};
options = Object.assign({}, options);
// Ensure we have the right read preference inheritance
... | [
"function",
"distinct",
"(",
"coll",
",",
"key",
",",
"query",
",",
"options",
",",
"callback",
")",
"{",
"// maxTimeMS option",
"const",
"maxTimeMS",
"=",
"options",
".",
"maxTimeMS",
";",
"// Distinct command",
"const",
"cmd",
"=",
"{",
"distinct",
":",
"c... | Return a list of distinct values for the given key across a collection.
@method
@param {Collection} a Collection instance.
@param {string} key Field of the document to find distinct values for.
@param {object} query The query for filtering the set of documents to which we apply the distinct filter.
@param {object} [op... | [
"Return",
"a",
"list",
"of",
"distinct",
"values",
"for",
"the",
"given",
"key",
"across",
"a",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L391-L424 |
6,454 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | dropIndex | function dropIndex(coll, indexName, options, callback) {
// Delete index command
const cmd = { dropIndexes: coll.s.name, index: indexName };
// Decorate command with writeConcern if supported
applyWriteConcern(cmd, { db: coll.s.db, collection: coll }, options);
// Execute command
executeCommand(coll.s.db,... | javascript | function dropIndex(coll, indexName, options, callback) {
// Delete index command
const cmd = { dropIndexes: coll.s.name, index: indexName };
// Decorate command with writeConcern if supported
applyWriteConcern(cmd, { db: coll.s.db, collection: coll }, options);
// Execute command
executeCommand(coll.s.db,... | [
"function",
"dropIndex",
"(",
"coll",
",",
"indexName",
",",
"options",
",",
"callback",
")",
"{",
"// Delete index command",
"const",
"cmd",
"=",
"{",
"dropIndexes",
":",
"coll",
".",
"s",
".",
"name",
",",
"index",
":",
"indexName",
"}",
";",
"// Decorat... | Drop an index from this collection.
@method
@param {Collection} a Collection instance.
@param {string} indexName Name of the index to drop.
@param {object} [options] Optional settings. See Collection.prototype.dropIndex for a list of options.
@param {Collection~resultCallback} [callback] The command result callback | [
"Drop",
"an",
"index",
"from",
"this",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L435-L448 |
6,455 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | dropIndexes | function dropIndexes(coll, options, callback) {
dropIndex(coll, '*', options, err => {
if (err) return handleCallback(callback, err, false);
handleCallback(callback, null, true);
});
} | javascript | function dropIndexes(coll, options, callback) {
dropIndex(coll, '*', options, err => {
if (err) return handleCallback(callback, err, false);
handleCallback(callback, null, true);
});
} | [
"function",
"dropIndexes",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"dropIndex",
"(",
"coll",
",",
"'*'",
",",
"options",
",",
"err",
"=>",
"{",
"if",
"(",
"err",
")",
"return",
"handleCallback",
"(",
"callback",
",",
"err",
",",
"false"... | Drop all indexes from this collection.
@method
@param {Collection} a Collection instance.
@param {Object} [options] Optional settings. See Collection.prototype.dropIndexes for a list of options.
@param {Collection~resultCallback} [callback] The command result callback | [
"Drop",
"all",
"indexes",
"from",
"this",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L458-L463 |
6,456 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | ensureIndex | function ensureIndex(coll, fieldOrSpec, options, callback) {
ensureIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback);
} | javascript | function ensureIndex(coll, fieldOrSpec, options, callback) {
ensureIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback);
} | [
"function",
"ensureIndex",
"(",
"coll",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
"{",
"ensureIndexDb",
"(",
"coll",
".",
"s",
".",
"db",
",",
"coll",
".",
"s",
".",
"name",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
";",... | Ensure that an index exists. If the index does not exist, this function creates it.
@method
@param {Collection} a Collection instance.
@param {(string|object)} fieldOrSpec Defines the index.
@param {object} [options] Optional settings. See Collection.prototype.ensureIndex for a list of options.
@param {Collection~resu... | [
"Ensure",
"that",
"an",
"index",
"exists",
".",
"If",
"the",
"index",
"does",
"not",
"exist",
"this",
"function",
"creates",
"it",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L474-L476 |
6,457 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | findAndModify | function findAndModify(coll, query, sort, doc, options, callback) {
// Create findAndModify command object
const queryObject = {
findAndModify: coll.s.name,
query: query
};
sort = formattedOrderClause(sort);
if (sort) {
queryObject.sort = sort;
}
queryObject.new = options.new ? true : false;... | javascript | function findAndModify(coll, query, sort, doc, options, callback) {
// Create findAndModify command object
const queryObject = {
findAndModify: coll.s.name,
query: query
};
sort = formattedOrderClause(sort);
if (sort) {
queryObject.sort = sort;
}
queryObject.new = options.new ? true : false;... | [
"function",
"findAndModify",
"(",
"coll",
",",
"query",
",",
"sort",
",",
"doc",
",",
"options",
",",
"callback",
")",
"{",
"// Create findAndModify command object",
"const",
"queryObject",
"=",
"{",
"findAndModify",
":",
"coll",
".",
"s",
".",
"name",
",",
... | Find and update a document.
@method
@param {Collection} a Collection instance.
@param {object} query Query object to locate the object to modify.
@param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
@param {object} doc The fields/vals to be updated.
... | [
"Find",
"and",
"update",
"a",
"document",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L490-L560 |
6,458 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | findAndRemove | function findAndRemove(coll, query, sort, options, callback) {
// Add the remove option
options.remove = true;
// Execute the callback
findAndModify(coll, query, sort, null, options, callback);
} | javascript | function findAndRemove(coll, query, sort, options, callback) {
// Add the remove option
options.remove = true;
// Execute the callback
findAndModify(coll, query, sort, null, options, callback);
} | [
"function",
"findAndRemove",
"(",
"coll",
",",
"query",
",",
"sort",
",",
"options",
",",
"callback",
")",
"{",
"// Add the remove option",
"options",
".",
"remove",
"=",
"true",
";",
"// Execute the callback",
"findAndModify",
"(",
"coll",
",",
"query",
",",
... | Find and remove a document.
@method
@param {Collection} a Collection instance.
@param {object} query Query object to locate the object to modify.
@param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
@param {object} [options] Optional settings. See Co... | [
"Find",
"and",
"remove",
"a",
"document",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L573-L578 |
6,459 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | findOne | function findOne(coll, query, options, callback) {
const cursor = coll
.find(query, options)
.limit(-1)
.batchSize(1);
// Return the item
cursor.next((err, item) => {
if (err != null) return handleCallback(callback, toError(err), null);
handleCallback(callback, null, item);
});
} | javascript | function findOne(coll, query, options, callback) {
const cursor = coll
.find(query, options)
.limit(-1)
.batchSize(1);
// Return the item
cursor.next((err, item) => {
if (err != null) return handleCallback(callback, toError(err), null);
handleCallback(callback, null, item);
});
} | [
"function",
"findOne",
"(",
"coll",
",",
"query",
",",
"options",
",",
"callback",
")",
"{",
"const",
"cursor",
"=",
"coll",
".",
"find",
"(",
"query",
",",
"options",
")",
".",
"limit",
"(",
"-",
"1",
")",
".",
"batchSize",
"(",
"1",
")",
";",
"... | Fetch the first document that matches the query.
@method
@param {Collection} a Collection instance.
@param {object} query Query for find Operation
@param {object} [options] Optional settings. See Collection.prototype.findOne for a list of options.
@param {Collection~resultCallback} [callback] The command result callba... | [
"Fetch",
"the",
"first",
"document",
"that",
"matches",
"the",
"query",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L589-L600 |
6,460 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | findOneAndDelete | function findOneAndDelete(coll, filter, options, callback) {
// Final options
const finalOptions = Object.assign({}, options);
finalOptions.fields = options.projection;
finalOptions.remove = true;
// Execute find and Modify
findAndModify(coll, filter, options.sort, null, finalOptions, callback);
} | javascript | function findOneAndDelete(coll, filter, options, callback) {
// Final options
const finalOptions = Object.assign({}, options);
finalOptions.fields = options.projection;
finalOptions.remove = true;
// Execute find and Modify
findAndModify(coll, filter, options.sort, null, finalOptions, callback);
} | [
"function",
"findOneAndDelete",
"(",
"coll",
",",
"filter",
",",
"options",
",",
"callback",
")",
"{",
"// Final options",
"const",
"finalOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
")",
";",
"finalOptions",
".",
"fields",
"=",
"... | Find a document and delete it in one atomic operation. This requires a write lock for the duration of the operation.
@method
@param {Collection} a Collection instance.
@param {object} filter Document selection filter.
@param {object} [options] Optional settings. See Collection.prototype.findOneAndDelete for a list of ... | [
"Find",
"a",
"document",
"and",
"delete",
"it",
"in",
"one",
"atomic",
"operation",
".",
"This",
"requires",
"a",
"write",
"lock",
"for",
"the",
"duration",
"of",
"the",
"operation",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L611-L618 |
6,461 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | findOneAndReplace | function findOneAndReplace(coll, filter, replacement, options, callback) {
// Final options
const finalOptions = Object.assign({}, options);
finalOptions.fields = options.projection;
finalOptions.update = true;
finalOptions.new = options.returnOriginal !== void 0 ? !options.returnOriginal : false;
finalOpti... | javascript | function findOneAndReplace(coll, filter, replacement, options, callback) {
// Final options
const finalOptions = Object.assign({}, options);
finalOptions.fields = options.projection;
finalOptions.update = true;
finalOptions.new = options.returnOriginal !== void 0 ? !options.returnOriginal : false;
finalOpti... | [
"function",
"findOneAndReplace",
"(",
"coll",
",",
"filter",
",",
"replacement",
",",
"options",
",",
"callback",
")",
"{",
"// Final options",
"const",
"finalOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
")",
";",
"finalOptions",
".... | Find a document and replace it in one atomic operation. This requires a write lock for the duration of the operation.
@method
@param {Collection} a Collection instance.
@param {object} filter Document selection filter.
@param {object} replacement Document replacing the matching document.
@param {object} [options] Opti... | [
"Find",
"a",
"document",
"and",
"replace",
"it",
"in",
"one",
"atomic",
"operation",
".",
"This",
"requires",
"a",
"write",
"lock",
"for",
"the",
"duration",
"of",
"the",
"operation",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L630-L640 |
6,462 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | geoHaystackSearch | function geoHaystackSearch(coll, x, y, options, callback) {
// Build command object
let commandObject = {
geoSearch: coll.s.name,
near: [x, y]
};
// Remove read preference from hash if it exists
commandObject = decorateCommand(commandObject, options, ['readPreference', 'session']);
options = Objec... | javascript | function geoHaystackSearch(coll, x, y, options, callback) {
// Build command object
let commandObject = {
geoSearch: coll.s.name,
near: [x, y]
};
// Remove read preference from hash if it exists
commandObject = decorateCommand(commandObject, options, ['readPreference', 'session']);
options = Objec... | [
"function",
"geoHaystackSearch",
"(",
"coll",
",",
"x",
",",
"y",
",",
"options",
",",
"callback",
")",
"{",
"// Build command object",
"let",
"commandObject",
"=",
"{",
"geoSearch",
":",
"coll",
".",
"s",
".",
"name",
",",
"near",
":",
"[",
"x",
",",
... | Execute a geo search using a geo haystack index on a collection.
@method
@param {Collection} a Collection instance.
@param {number} x Point to search on the x axis, ensure the indexes are ordered in the same order.
@param {number} y Point to search on the y axis, ensure the indexes are ordered in the same order.
@para... | [
"Execute",
"a",
"geo",
"search",
"using",
"a",
"geo",
"haystack",
"index",
"on",
"a",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L674-L699 |
6,463 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | group | function group(coll, keys, condition, initial, reduce, finalize, command, options, callback) {
// Execute using the command
if (command) {
const reduceFunction = reduce && reduce._bsontype === 'Code' ? reduce : new Code(reduce);
const selector = {
group: {
ns: coll.s.name,
$reduce: re... | javascript | function group(coll, keys, condition, initial, reduce, finalize, command, options, callback) {
// Execute using the command
if (command) {
const reduceFunction = reduce && reduce._bsontype === 'Code' ? reduce : new Code(reduce);
const selector = {
group: {
ns: coll.s.name,
$reduce: re... | [
"function",
"group",
"(",
"coll",
",",
"keys",
",",
"condition",
",",
"initial",
",",
"reduce",
",",
"finalize",
",",
"command",
",",
"options",
",",
"callback",
")",
"{",
"// Execute using the command",
"if",
"(",
"command",
")",
"{",
"const",
"reduceFuncti... | Run a group command across a collection.
@method
@param {Collection} a Collection instance.
@param {(object|array|function|code)} keys An object, array or function expressing the keys to group by.
@param {object} condition An optional condition that must be true for a row to be considered.
@param {object} initial Init... | [
"Run",
"a",
"group",
"command",
"across",
"a",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L716-L780 |
6,464 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | indexes | function indexes(coll, options, callback) {
options = Object.assign({}, { full: true }, options);
indexInformationDb(coll.s.db, coll.s.name, options, callback);
} | javascript | function indexes(coll, options, callback) {
options = Object.assign({}, { full: true }, options);
indexInformationDb(coll.s.db, coll.s.name, options, callback);
} | [
"function",
"indexes",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"{",
"full",
":",
"true",
"}",
",",
"options",
")",
";",
"indexInformationDb",
"(",
"coll",
".",
"s",
".",
"... | Retrieve all the indexes on the collection.
@method
@param {Collection} a Collection instance.
@param {Object} [options] Optional settings. See Collection.prototype.indexes for a list of options.
@param {Collection~resultCallback} [callback] The command result callback | [
"Retrieve",
"all",
"the",
"indexes",
"on",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L790-L793 |
6,465 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | indexExists | function indexExists(coll, indexes, options, callback) {
indexInformation(coll, options, (err, indexInformation) => {
// If we have an error return
if (err != null) return handleCallback(callback, err, null);
// Let's check for the index names
if (!Array.isArray(indexes))
return handleCallback(c... | javascript | function indexExists(coll, indexes, options, callback) {
indexInformation(coll, options, (err, indexInformation) => {
// If we have an error return
if (err != null) return handleCallback(callback, err, null);
// Let's check for the index names
if (!Array.isArray(indexes))
return handleCallback(c... | [
"function",
"indexExists",
"(",
"coll",
",",
"indexes",
",",
"options",
",",
"callback",
")",
"{",
"indexInformation",
"(",
"coll",
",",
"options",
",",
"(",
"err",
",",
"indexInformation",
")",
"=>",
"{",
"// If we have an error return",
"if",
"(",
"err",
"... | Check if one or more indexes exist on the collection. This fails on the first index that doesn't exist.
@method
@param {Collection} a Collection instance.
@param {(string|array)} indexes One or more index names to check.
@param {Object} [options] Optional settings. See Collection.prototype.indexExists for a list of op... | [
"Check",
"if",
"one",
"or",
"more",
"indexes",
"exist",
"on",
"the",
"collection",
".",
"This",
"fails",
"on",
"the",
"first",
"index",
"that",
"doesn",
"t",
"exist",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L804-L821 |
6,466 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | indexInformation | function indexInformation(coll, options, callback) {
indexInformationDb(coll.s.db, coll.s.name, options, callback);
} | javascript | function indexInformation(coll, options, callback) {
indexInformationDb(coll.s.db, coll.s.name, options, callback);
} | [
"function",
"indexInformation",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"indexInformationDb",
"(",
"coll",
".",
"s",
".",
"db",
",",
"coll",
".",
"s",
".",
"name",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Retrieve this collection's index info.
@method
@param {Collection} a Collection instance.
@param {object} [options] Optional settings. See Collection.prototype.indexInformation for a list of options.
@param {Collection~resultCallback} [callback] The command result callback | [
"Retrieve",
"this",
"collection",
"s",
"index",
"info",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L831-L833 |
6,467 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | insertOne | function insertOne(coll, doc, options, callback) {
if (Array.isArray(doc)) {
return callback(
MongoError.create({ message: 'doc parameter must be an object', driver: true })
);
}
insertDocuments(coll, [doc], options, (err, r) => {
if (callback == null) return;
if (err && callback) return ca... | javascript | function insertOne(coll, doc, options, callback) {
if (Array.isArray(doc)) {
return callback(
MongoError.create({ message: 'doc parameter must be an object', driver: true })
);
}
insertDocuments(coll, [doc], options, (err, r) => {
if (callback == null) return;
if (err && callback) return ca... | [
"function",
"insertOne",
"(",
"coll",
",",
"doc",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"doc",
")",
")",
"{",
"return",
"callback",
"(",
"MongoError",
".",
"create",
"(",
"{",
"message",
":",
"'doc paramete... | Insert a single document into the collection. See Collection.prototype.insertOne for more information.
@method
@param {Collection} a Collection instance.
@param {object} doc Document to insert.
@param {object} [options] Optional settings. See Collection.prototype.insertOne for a list of options.
@param {Collection~ins... | [
"Insert",
"a",
"single",
"document",
"into",
"the",
"collection",
".",
"See",
"Collection",
".",
"prototype",
".",
"insertOne",
"for",
"more",
"information",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L876-L893 |
6,468 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | isCapped | function isCapped(coll, options, callback) {
optionsOp(coll, options, (err, document) => {
if (err) return handleCallback(callback, err);
handleCallback(callback, null, !!(document && document.capped));
});
} | javascript | function isCapped(coll, options, callback) {
optionsOp(coll, options, (err, document) => {
if (err) return handleCallback(callback, err);
handleCallback(callback, null, !!(document && document.capped));
});
} | [
"function",
"isCapped",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"optionsOp",
"(",
"coll",
",",
"options",
",",
"(",
"err",
",",
"document",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"return",
"handleCallback",
"(",
"callback",
",",
"err",
... | Determine whether the collection is a capped collection.
@method
@param {Collection} a Collection instance.
@param {Object} [options] Optional settings. See Collection.prototype.isCapped for a list of options.
@param {Collection~resultCallback} [callback] The results callback | [
"Determine",
"whether",
"the",
"collection",
"is",
"a",
"capped",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L954-L959 |
6,469 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | optionsOp | function optionsOp(coll, opts, callback) {
coll.s.db.listCollections({ name: coll.s.name }, opts).toArray((err, collections) => {
if (err) return handleCallback(callback, err);
if (collections.length === 0) {
return handleCallback(
callback,
MongoError.create({ message: `collection ${col... | javascript | function optionsOp(coll, opts, callback) {
coll.s.db.listCollections({ name: coll.s.name }, opts).toArray((err, collections) => {
if (err) return handleCallback(callback, err);
if (collections.length === 0) {
return handleCallback(
callback,
MongoError.create({ message: `collection ${col... | [
"function",
"optionsOp",
"(",
"coll",
",",
"opts",
",",
"callback",
")",
"{",
"coll",
".",
"s",
".",
"db",
".",
"listCollections",
"(",
"{",
"name",
":",
"coll",
".",
"s",
".",
"name",
"}",
",",
"opts",
")",
".",
"toArray",
"(",
"(",
"err",
",",
... | Return the options of the collection.
@method
@param {Collection} a Collection instance.
@param {Object} [options] Optional settings. See Collection.prototype.options for a list of options.
@param {Collection~resultCallback} [callback] The results callback | [
"Return",
"the",
"options",
"of",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1083-L1095 |
6,470 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | parallelCollectionScan | function parallelCollectionScan(coll, options, callback) {
// Create command object
const commandObject = {
parallelCollectionScan: coll.s.name,
numCursors: options.numCursors
};
// Do we have a readConcern specified
decorateWithReadConcern(commandObject, coll, options);
// Store the raw value
c... | javascript | function parallelCollectionScan(coll, options, callback) {
// Create command object
const commandObject = {
parallelCollectionScan: coll.s.name,
numCursors: options.numCursors
};
// Do we have a readConcern specified
decorateWithReadConcern(commandObject, coll, options);
// Store the raw value
c... | [
"function",
"parallelCollectionScan",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"// Create command object",
"const",
"commandObject",
"=",
"{",
"parallelCollectionScan",
":",
"coll",
".",
"s",
".",
"name",
",",
"numCursors",
":",
"options",
".",
"n... | Return N parallel cursors for a collection to allow parallel reading of the entire collection. There are
no ordering guarantees for returned results.
@method
@param {Collection} a Collection instance.
@param {object} [options] Optional settings. See Collection.prototype.parallelCollectionScan for a list of options.
@p... | [
"Return",
"N",
"parallel",
"cursors",
"for",
"a",
"collection",
"to",
"allow",
"parallel",
"reading",
"of",
"the",
"entire",
"collection",
".",
"There",
"are",
"no",
"ordering",
"guarantees",
"for",
"returned",
"results",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1106-L1146 |
6,471 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | prepareDocs | function prepareDocs(coll, docs, options) {
const forceServerObjectId =
typeof options.forceServerObjectId === 'boolean'
? options.forceServerObjectId
: coll.s.db.options.forceServerObjectId;
// no need to modify the docs if server sets the ObjectId
if (forceServerObjectId === true) {
return ... | javascript | function prepareDocs(coll, docs, options) {
const forceServerObjectId =
typeof options.forceServerObjectId === 'boolean'
? options.forceServerObjectId
: coll.s.db.options.forceServerObjectId;
// no need to modify the docs if server sets the ObjectId
if (forceServerObjectId === true) {
return ... | [
"function",
"prepareDocs",
"(",
"coll",
",",
"docs",
",",
"options",
")",
"{",
"const",
"forceServerObjectId",
"=",
"typeof",
"options",
".",
"forceServerObjectId",
"===",
"'boolean'",
"?",
"options",
".",
"forceServerObjectId",
":",
"coll",
".",
"s",
".",
"db... | modifies documents before being inserted or updated | [
"modifies",
"documents",
"before",
"being",
"inserted",
"or",
"updated"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1149-L1167 |
6,472 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | processScope | function processScope(scope) {
if (!isObject(scope) || scope._bsontype === 'ObjectID') {
return scope;
}
const keys = Object.keys(scope);
let key;
const new_scope = {};
for (let i = keys.length - 1; i >= 0; i--) {
key = keys[i];
if ('function' === typeof scope[key]) {
new_scope[key] = ne... | javascript | function processScope(scope) {
if (!isObject(scope) || scope._bsontype === 'ObjectID') {
return scope;
}
const keys = Object.keys(scope);
let key;
const new_scope = {};
for (let i = keys.length - 1; i >= 0; i--) {
key = keys[i];
if ('function' === typeof scope[key]) {
new_scope[key] = ne... | [
"function",
"processScope",
"(",
"scope",
")",
"{",
"if",
"(",
"!",
"isObject",
"(",
"scope",
")",
"||",
"scope",
".",
"_bsontype",
"===",
"'ObjectID'",
")",
"{",
"return",
"scope",
";",
"}",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"scope",
... | Functions that are passed as scope args must
be converted to Code instances.
@ignore | [
"Functions",
"that",
"are",
"passed",
"as",
"scope",
"args",
"must",
"be",
"converted",
"to",
"Code",
"instances",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1174-L1193 |
6,473 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | reIndex | function reIndex(coll, options, callback) {
// Reindex
const cmd = { reIndex: coll.s.name };
// Execute the command
executeCommand(coll.s.db, cmd, options, (err, result) => {
if (callback == null) return;
if (err) return handleCallback(callback, err, null);
handleCallback(callback, null, result.ok ... | javascript | function reIndex(coll, options, callback) {
// Reindex
const cmd = { reIndex: coll.s.name };
// Execute the command
executeCommand(coll.s.db, cmd, options, (err, result) => {
if (callback == null) return;
if (err) return handleCallback(callback, err, null);
handleCallback(callback, null, result.ok ... | [
"function",
"reIndex",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"// Reindex",
"const",
"cmd",
"=",
"{",
"reIndex",
":",
"coll",
".",
"s",
".",
"name",
"}",
";",
"// Execute the command",
"executeCommand",
"(",
"coll",
".",
"s",
".",
"db",
... | Reindex all indexes on the collection.
@method
@param {Collection} a Collection instance.
@param {Object} [options] Optional settings. See Collection.prototype.reIndex for a list of options.
@param {Collection~resultCallback} [callback] The command result callback | [
"Reindex",
"all",
"indexes",
"on",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1203-L1213 |
6,474 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | replaceOne | function replaceOne(coll, filter, doc, options, callback) {
// Set single document update
options.multi = false;
// Execute update
updateDocuments(coll, filter, doc, options, (err, r) => {
if (callback == null) return;
if (err && callback) return callback(err);
if (r == null) return callback(null, ... | javascript | function replaceOne(coll, filter, doc, options, callback) {
// Set single document update
options.multi = false;
// Execute update
updateDocuments(coll, filter, doc, options, (err, r) => {
if (callback == null) return;
if (err && callback) return callback(err);
if (r == null) return callback(null, ... | [
"function",
"replaceOne",
"(",
"coll",
",",
"filter",
",",
"doc",
",",
"options",
",",
"callback",
")",
"{",
"// Set single document update",
"options",
".",
"multi",
"=",
"false",
";",
"// Execute update",
"updateDocuments",
"(",
"coll",
",",
"filter",
",",
"... | Replace a document in the collection.
@method
@param {Collection} a Collection instance.
@param {object} filter The Filter used to select the document to update
@param {object} doc The Document that replaces the matching document
@param {object} [options] Optional settings. See Collection.prototype.replaceOne for a li... | [
"Replace",
"a",
"document",
"in",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1319-L1341 |
6,475 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | save | function save(coll, doc, options, callback) {
// Get the write concern options
const finalOptions = applyWriteConcern(
Object.assign({}, options),
{ db: coll.s.db, collection: coll },
options
);
// Establish if we need to perform an insert or update
if (doc._id != null) {
finalOptions.upsert =... | javascript | function save(coll, doc, options, callback) {
// Get the write concern options
const finalOptions = applyWriteConcern(
Object.assign({}, options),
{ db: coll.s.db, collection: coll },
options
);
// Establish if we need to perform an insert or update
if (doc._id != null) {
finalOptions.upsert =... | [
"function",
"save",
"(",
"coll",
",",
"doc",
",",
"options",
",",
"callback",
")",
"{",
"// Get the write concern options",
"const",
"finalOptions",
"=",
"applyWriteConcern",
"(",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
")",
",",
"{",
"db",
... | Save a document.
@method
@param {Collection} a Collection instance.
@param {object} doc Document to save
@param {object} [options] Optional settings. See Collection.prototype.save for a list of options.
@param {Collection~writeOpCallback} [callback] The command result callback
@deprecated use insertOne, insertMany, up... | [
"Save",
"a",
"document",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1353-L1373 |
6,476 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | stats | function stats(coll, options, callback) {
// Build command object
const commandObject = {
collStats: coll.s.name
};
// Check if we have the scale value
if (options['scale'] != null) commandObject['scale'] = options['scale'];
options = Object.assign({}, options);
// Ensure we have the right read pref... | javascript | function stats(coll, options, callback) {
// Build command object
const commandObject = {
collStats: coll.s.name
};
// Check if we have the scale value
if (options['scale'] != null) commandObject['scale'] = options['scale'];
options = Object.assign({}, options);
// Ensure we have the right read pref... | [
"function",
"stats",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"// Build command object",
"const",
"commandObject",
"=",
"{",
"collStats",
":",
"coll",
".",
"s",
".",
"name",
"}",
";",
"// Check if we have the scale value",
"if",
"(",
"options",
... | Get all the collection statistics.
@method
@param {Collection} a Collection instance.
@param {object} [options] Optional settings. See Collection.prototype.stats for a list of options.
@param {Collection~resultCallback} [callback] The collection result callback | [
"Get",
"all",
"the",
"collection",
"statistics",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1383-L1398 |
6,477 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | updateMany | function updateMany(coll, filter, update, options, callback) {
// Set single document update
options.multi = true;
// Execute update
updateDocuments(coll, filter, update, options, (err, r) => updateCallback(err, r, callback));
} | javascript | function updateMany(coll, filter, update, options, callback) {
// Set single document update
options.multi = true;
// Execute update
updateDocuments(coll, filter, update, options, (err, r) => updateCallback(err, r, callback));
} | [
"function",
"updateMany",
"(",
"coll",
",",
"filter",
",",
"update",
",",
"options",
",",
"callback",
")",
"{",
"// Set single document update",
"options",
".",
"multi",
"=",
"true",
";",
"// Execute update",
"updateDocuments",
"(",
"coll",
",",
"filter",
",",
... | Update multiple documents in the collection.
@method
@param {Collection} a Collection instance.
@param {object} filter The Filter used to select the documents to update
@param {object} update The update operations to be applied to the document
@param {object} [options] Optional settings. See Collection.prototype.updat... | [
"Update",
"multiple",
"documents",
"in",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1481-L1486 |
6,478 | mongodb/node-mongodb-native | lib/operations/collection_ops.js | updateOne | function updateOne(coll, filter, update, options, callback) {
// Set single document update
options.multi = false;
// Execute update
updateDocuments(coll, filter, update, options, (err, r) => updateCallback(err, r, callback));
} | javascript | function updateOne(coll, filter, update, options, callback) {
// Set single document update
options.multi = false;
// Execute update
updateDocuments(coll, filter, update, options, (err, r) => updateCallback(err, r, callback));
} | [
"function",
"updateOne",
"(",
"coll",
",",
"filter",
",",
"update",
",",
"options",
",",
"callback",
")",
"{",
"// Set single document update",
"options",
".",
"multi",
"=",
"false",
";",
"// Execute update",
"updateDocuments",
"(",
"coll",
",",
"filter",
",",
... | Update a single document in the collection.
@method
@param {Collection} a Collection instance.
@param {object} filter The Filter used to select the document to update
@param {object} update The update operations to be applied to the document
@param {object} [options] Optional settings. See Collection.prototype.updateO... | [
"Update",
"a",
"single",
"document",
"in",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1498-L1503 |
6,479 | mongodb/node-mongodb-native | lib/topologies/topology_base.js | function(topology, storeOptions) {
var self = this;
var storedOps = [];
storeOptions = storeOptions || { force: false, bufferMaxEntries: -1 };
// Internal state
this.s = {
storedOps: storedOps,
storeOptions: storeOptions,
topology: topology
};
Object.defineProperty(this, 'length', {
enum... | javascript | function(topology, storeOptions) {
var self = this;
var storedOps = [];
storeOptions = storeOptions || { force: false, bufferMaxEntries: -1 };
// Internal state
this.s = {
storedOps: storedOps,
storeOptions: storeOptions,
topology: topology
};
Object.defineProperty(this, 'length', {
enum... | [
"function",
"(",
"topology",
",",
"storeOptions",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"storedOps",
"=",
"[",
"]",
";",
"storeOptions",
"=",
"storeOptions",
"||",
"{",
"force",
":",
"false",
",",
"bufferMaxEntries",
":",
"-",
"1",
"}",
";"... | The store of ops | [
"The",
"store",
"of",
"ops"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/topologies/topology_base.js#L11-L29 | |
6,480 | mongodb/node-mongodb-native | lib/gridfs-stream/upload.js | GridFSBucketWriteStream | function GridFSBucketWriteStream(bucket, filename, options) {
options = options || {};
this.bucket = bucket;
this.chunks = bucket.s._chunksCollection;
this.filename = filename;
this.files = bucket.s._filesCollection;
this.options = options;
// Signals the write is all done
this.done = false;
this.id ... | javascript | function GridFSBucketWriteStream(bucket, filename, options) {
options = options || {};
this.bucket = bucket;
this.chunks = bucket.s._chunksCollection;
this.filename = filename;
this.files = bucket.s._filesCollection;
this.options = options;
// Signals the write is all done
this.done = false;
this.id ... | [
"function",
"GridFSBucketWriteStream",
"(",
"bucket",
",",
"filename",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"bucket",
"=",
"bucket",
";",
"this",
".",
"chunks",
"=",
"bucket",
".",
"s",
".",
"_chunksColle... | A writable stream that enables you to write buffers to GridFS.
Do not instantiate this class directly. Use `openUploadStream()` instead.
@class
@param {GridFSBucket} bucket Handle for this stream's corresponding bucket
@param {string} filename The value of the 'filename' key in the files doc
@param {object} [options]... | [
"A",
"writable",
"stream",
"that",
"enables",
"you",
"to",
"write",
"buffers",
"to",
"GridFS",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs-stream/upload.js#L33-L67 |
6,481 | mongodb/node-mongodb-native | lib/utils.js | function(options) {
var r = null;
if (options.readPreference) {
r = options.readPreference;
} else {
return options;
}
if (typeof r === 'string') {
options.readPreference = new ReadPreference(r);
} else if (r && !(r instanceof ReadPreference) && typeof r === 'object') {
const mode = r.mode ... | javascript | function(options) {
var r = null;
if (options.readPreference) {
r = options.readPreference;
} else {
return options;
}
if (typeof r === 'string') {
options.readPreference = new ReadPreference(r);
} else if (r && !(r instanceof ReadPreference) && typeof r === 'object') {
const mode = r.mode ... | [
"function",
"(",
"options",
")",
"{",
"var",
"r",
"=",
"null",
";",
"if",
"(",
"options",
".",
"readPreference",
")",
"{",
"r",
"=",
"options",
".",
"readPreference",
";",
"}",
"else",
"{",
"return",
"options",
";",
"}",
"if",
"(",
"typeof",
"r",
"... | Figure out the read preference | [
"Figure",
"out",
"the",
"read",
"preference"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L13-L35 | |
6,482 | mongodb/node-mongodb-native | lib/utils.js | function(obj, name, value) {
Object.defineProperty(obj, name, {
enumerable: true,
get: function() {
return value;
}
});
} | javascript | function(obj, name, value) {
Object.defineProperty(obj, name, {
enumerable: true,
get: function() {
return value;
}
});
} | [
"function",
"(",
"obj",
",",
"name",
",",
"value",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"obj",
",",
"name",
",",
"{",
"enumerable",
":",
"true",
",",
"get",
":",
"function",
"(",
")",
"{",
"return",
"value",
";",
"}",
"}",
")",
";",
"}... | Set simple property | [
"Set",
"simple",
"property"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L38-L45 | |
6,483 | mongodb/node-mongodb-native | lib/utils.js | function(error) {
if (error instanceof Error) return error;
var msg = error.err || error.errmsg || error.errMessage || error;
var e = MongoError.create({ message: msg, driver: true });
// Get all object keys
var keys = typeof error === 'object' ? Object.keys(error) : [];
for (var i = 0; i < keys.length; ... | javascript | function(error) {
if (error instanceof Error) return error;
var msg = error.err || error.errmsg || error.errMessage || error;
var e = MongoError.create({ message: msg, driver: true });
// Get all object keys
var keys = typeof error === 'object' ? Object.keys(error) : [];
for (var i = 0; i < keys.length; ... | [
"function",
"(",
"error",
")",
"{",
"if",
"(",
"error",
"instanceof",
"Error",
")",
"return",
"error",
";",
"var",
"msg",
"=",
"error",
".",
"err",
"||",
"error",
".",
"errmsg",
"||",
"error",
".",
"errMessage",
"||",
"error",
";",
"var",
"e",
"=",
... | Wrap a Mongo error document in an Error instance
@ignore
@api private | [
"Wrap",
"a",
"Mongo",
"error",
"document",
"in",
"an",
"Error",
"instance"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L145-L163 | |
6,484 | mongodb/node-mongodb-native | lib/utils.js | function(fieldOrSpec) {
var fieldHash = {};
var indexes = [];
var keys;
// Get all the fields accordingly
if ('string' === typeof fieldOrSpec) {
// 'type'
indexes.push(fieldOrSpec + '_' + 1);
fieldHash[fieldOrSpec] = 1;
} else if (Array.isArray(fieldOrSpec)) {
fieldOrSpec.forEach(function(f... | javascript | function(fieldOrSpec) {
var fieldHash = {};
var indexes = [];
var keys;
// Get all the fields accordingly
if ('string' === typeof fieldOrSpec) {
// 'type'
indexes.push(fieldOrSpec + '_' + 1);
fieldHash[fieldOrSpec] = 1;
} else if (Array.isArray(fieldOrSpec)) {
fieldOrSpec.forEach(function(f... | [
"function",
"(",
"fieldOrSpec",
")",
"{",
"var",
"fieldHash",
"=",
"{",
"}",
";",
"var",
"indexes",
"=",
"[",
"]",
";",
"var",
"keys",
";",
"// Get all the fields accordingly",
"if",
"(",
"'string'",
"===",
"typeof",
"fieldOrSpec",
")",
"{",
"// 'type'",
"... | Create index name based on field spec
@ignore
@api private | [
"Create",
"index",
"name",
"based",
"on",
"field",
"spec"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L195-L240 | |
6,485 | mongodb/node-mongodb-native | lib/utils.js | function(target, source) {
var translations = {
// SSL translation options
sslCA: 'ca',
sslCRL: 'crl',
sslValidate: 'rejectUnauthorized',
sslKey: 'key',
sslCert: 'cert',
sslPass: 'passphrase',
// SocketTimeout translation options
socketTimeoutMS: 'socketTimeout',
connectTimeout... | javascript | function(target, source) {
var translations = {
// SSL translation options
sslCA: 'ca',
sslCRL: 'crl',
sslValidate: 'rejectUnauthorized',
sslKey: 'key',
sslCert: 'cert',
sslPass: 'passphrase',
// SocketTimeout translation options
socketTimeoutMS: 'socketTimeout',
connectTimeout... | [
"function",
"(",
"target",
",",
"source",
")",
"{",
"var",
"translations",
"=",
"{",
"// SSL translation options",
"sslCA",
":",
"'ca'",
",",
"sslCRL",
":",
"'crl'",
",",
"sslValidate",
":",
"'rejectUnauthorized'",
",",
"sslKey",
":",
"'key'",
",",
"sslCert",
... | Merge options with translation | [
"Merge",
"options",
"with",
"translation"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L272-L302 | |
6,486 | mongodb/node-mongodb-native | lib/utils.js | function(targetOptions, sourceOptions, keys, mergeWriteConcern) {
// Mix in any allowed options
for (var i = 0; i < keys.length; i++) {
if (!targetOptions[keys[i]] && sourceOptions[keys[i]] !== undefined) {
targetOptions[keys[i]] = sourceOptions[keys[i]];
}
}
// No merging of write concern
if (... | javascript | function(targetOptions, sourceOptions, keys, mergeWriteConcern) {
// Mix in any allowed options
for (var i = 0; i < keys.length; i++) {
if (!targetOptions[keys[i]] && sourceOptions[keys[i]] !== undefined) {
targetOptions[keys[i]] = sourceOptions[keys[i]];
}
}
// No merging of write concern
if (... | [
"function",
"(",
"targetOptions",
",",
"sourceOptions",
",",
"keys",
",",
"mergeWriteConcern",
")",
"{",
"// Mix in any allowed options",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
... | Merge the write concern options | [
"Merge",
"the",
"write",
"concern",
"options"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L319-L348 | |
6,487 | mongodb/node-mongodb-native | lib/utils.js | applyWriteConcern | function applyWriteConcern(target, sources, options) {
options = options || {};
const db = sources.db;
const coll = sources.collection;
if (options.session && options.session.inTransaction()) {
// writeConcern is not allowed within a multi-statement transaction
if (target.writeConcern) {
delete t... | javascript | function applyWriteConcern(target, sources, options) {
options = options || {};
const db = sources.db;
const coll = sources.collection;
if (options.session && options.session.inTransaction()) {
// writeConcern is not allowed within a multi-statement transaction
if (target.writeConcern) {
delete t... | [
"function",
"applyWriteConcern",
"(",
"target",
",",
"sources",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"const",
"db",
"=",
"sources",
".",
"db",
";",
"const",
"coll",
"=",
"sources",
".",
"collection",
";",
"if",
"(",... | Applies a write concern to a command based on well defined inheritance rules, optionally
detecting support for the write concern in the first place.
@param {Object} target the target command we will be applying the write concern to
@param {Object} sources sources where we can inherit default write concerns from
@param... | [
"Applies",
"a",
"write",
"concern",
"to",
"a",
"command",
"based",
"on",
"well",
"defined",
"inheritance",
"rules",
"optionally",
"detecting",
"support",
"for",
"the",
"write",
"concern",
"in",
"the",
"first",
"place",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L463-L501 |
6,488 | mongodb/node-mongodb-native | lib/utils.js | deprecateOptions | function deprecateOptions(config, fn) {
if (process.noDeprecation === true) {
return fn;
}
const msgHandler = config.msgHandler ? config.msgHandler : defaultMsgHandler;
const optionsWarned = new Set();
function deprecated() {
const options = arguments[config.optionsIndex];
// ensure options is ... | javascript | function deprecateOptions(config, fn) {
if (process.noDeprecation === true) {
return fn;
}
const msgHandler = config.msgHandler ? config.msgHandler : defaultMsgHandler;
const optionsWarned = new Set();
function deprecated() {
const options = arguments[config.optionsIndex];
// ensure options is ... | [
"function",
"deprecateOptions",
"(",
"config",
",",
"fn",
")",
"{",
"if",
"(",
"process",
".",
"noDeprecation",
"===",
"true",
")",
"{",
"return",
"fn",
";",
"}",
"const",
"msgHandler",
"=",
"config",
".",
"msgHandler",
"?",
"config",
".",
"msgHandler",
... | Deprecates a given function's options.
@param {object} config configuration for deprecation
@param {string} config.name function name
@param {Array} config.deprecatedOptions options to deprecate
@param {number} config.optionsIndex index of options object in function arguments array
@param {function} [config.msgHandler... | [
"Deprecates",
"a",
"given",
"function",
"s",
"options",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L647-L691 |
6,489 | mongodb/node-mongodb-native | lib/operations/cursor_ops.js | count | function count(cursor, applySkipLimit, opts, callback) {
if (applySkipLimit) {
if (typeof cursor.cursorSkip() === 'number') opts.skip = cursor.cursorSkip();
if (typeof cursor.cursorLimit() === 'number') opts.limit = cursor.cursorLimit();
}
// Ensure we have the right read preference inheritance
if (opt... | javascript | function count(cursor, applySkipLimit, opts, callback) {
if (applySkipLimit) {
if (typeof cursor.cursorSkip() === 'number') opts.skip = cursor.cursorSkip();
if (typeof cursor.cursorLimit() === 'number') opts.limit = cursor.cursorLimit();
}
// Ensure we have the right read preference inheritance
if (opt... | [
"function",
"count",
"(",
"cursor",
",",
"applySkipLimit",
",",
"opts",
",",
"callback",
")",
"{",
"if",
"(",
"applySkipLimit",
")",
"{",
"if",
"(",
"typeof",
"cursor",
".",
"cursorSkip",
"(",
")",
"===",
"'number'",
")",
"opts",
".",
"skip",
"=",
"cur... | Get the count of documents for this cursor.
@method
@param {Cursor} cursor The Cursor instance on which to count.
@param {boolean} [applySkipLimit=true] Specifies whether the count command apply limit and skip settings should be applied on the cursor or in the provided options.
@param {object} [options] Optional setti... | [
"Get",
"the",
"count",
"of",
"documents",
"for",
"this",
"cursor",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/cursor_ops.js#L26-L74 |
6,490 | mongodb/node-mongodb-native | lib/operations/cursor_ops.js | each | function each(cursor, callback) {
let Cursor = loadCursor();
if (!callback) throw MongoError.create({ message: 'callback is mandatory', driver: true });
if (cursor.isNotified()) return;
if (cursor.s.state === Cursor.CLOSED || cursor.isDead()) {
return handleCallback(
callback,
MongoError.create... | javascript | function each(cursor, callback) {
let Cursor = loadCursor();
if (!callback) throw MongoError.create({ message: 'callback is mandatory', driver: true });
if (cursor.isNotified()) return;
if (cursor.s.state === Cursor.CLOSED || cursor.isDead()) {
return handleCallback(
callback,
MongoError.create... | [
"function",
"each",
"(",
"cursor",
",",
"callback",
")",
"{",
"let",
"Cursor",
"=",
"loadCursor",
"(",
")",
";",
"if",
"(",
"!",
"callback",
")",
"throw",
"MongoError",
".",
"create",
"(",
"{",
"message",
":",
"'callback is mandatory'",
",",
"driver",
":... | Iterates over all the documents for this cursor. See Cursor.prototype.each for more information.
@method
@deprecated
@param {Cursor} cursor The Cursor instance on which to run.
@param {Cursor~resultCallback} callback The result callback. | [
"Iterates",
"over",
"all",
"the",
"documents",
"for",
"this",
"cursor",
".",
"See",
"Cursor",
".",
"prototype",
".",
"each",
"for",
"more",
"information",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/cursor_ops.js#L84-L115 |
6,491 | mongodb/node-mongodb-native | lib/operations/cursor_ops.js | next | function next(cursor, callback) {
// Return the currentDoc if someone called hasNext first
if (cursor.s.currentDoc) {
const doc = cursor.s.currentDoc;
cursor.s.currentDoc = null;
return callback(null, doc);
}
// Return the next object
nextObject(cursor, callback);
} | javascript | function next(cursor, callback) {
// Return the currentDoc if someone called hasNext first
if (cursor.s.currentDoc) {
const doc = cursor.s.currentDoc;
cursor.s.currentDoc = null;
return callback(null, doc);
}
// Return the next object
nextObject(cursor, callback);
} | [
"function",
"next",
"(",
"cursor",
",",
"callback",
")",
"{",
"// Return the currentDoc if someone called hasNext first",
"if",
"(",
"cursor",
".",
"s",
".",
"currentDoc",
")",
"{",
"const",
"doc",
"=",
"cursor",
".",
"s",
".",
"currentDoc",
";",
"cursor",
"."... | Get the next available document from the cursor. Returns null if no more documents are available.
@method
@param {Cursor} cursor The Cursor instance from which to get the next document.
@param {Cursor~resultCallback} [callback] The result callback. | [
"Get",
"the",
"next",
"available",
"document",
"from",
"the",
"cursor",
".",
"Returns",
"null",
"if",
"no",
"more",
"documents",
"are",
"available",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/cursor_ops.js#L162-L172 |
6,492 | mongodb/node-mongodb-native | lib/gridfs/chunk.js | function(file, mongoObject, writeConcern) {
if (!(this instanceof Chunk)) return new Chunk(file, mongoObject);
this.file = file;
var mongoObjectFinal = mongoObject == null ? {} : mongoObject;
this.writeConcern = writeConcern || { w: 1 };
this.objectId = mongoObjectFinal._id == null ? new ObjectID() : mongoOb... | javascript | function(file, mongoObject, writeConcern) {
if (!(this instanceof Chunk)) return new Chunk(file, mongoObject);
this.file = file;
var mongoObjectFinal = mongoObject == null ? {} : mongoObject;
this.writeConcern = writeConcern || { w: 1 };
this.objectId = mongoObjectFinal._id == null ? new ObjectID() : mongoOb... | [
"function",
"(",
"file",
",",
"mongoObject",
",",
"writeConcern",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Chunk",
")",
")",
"return",
"new",
"Chunk",
"(",
"file",
",",
"mongoObject",
")",
";",
"this",
".",
"file",
"=",
"file",
";",
"var... | Class for representing a single chunk in GridFS.
@class
@param file {GridStore} The {@link GridStore} object holding this chunk.
@param mongoObject {object} The mongo object representation of this chunk.
@throws Error when the type of data field for {@link mongoObject} is not
supported. Currently supported types for... | [
"Class",
"for",
"representing",
"a",
"single",
"chunk",
"in",
"GridFS",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs/chunk.js#L23-L50 | |
6,493 | mongodb/node-mongodb-native | lib/command_cursor.js | function(bson, ns, cmd, options, topology, topologyOptions) {
CoreCursor.apply(this, Array.prototype.slice.call(arguments, 0));
var state = CommandCursor.INIT;
var streamOptions = {};
// MaxTimeMS
var maxTimeMS = null;
// Get the promiseLibrary
var promiseLibrary = options.promiseLibrary || Promise;
... | javascript | function(bson, ns, cmd, options, topology, topologyOptions) {
CoreCursor.apply(this, Array.prototype.slice.call(arguments, 0));
var state = CommandCursor.INIT;
var streamOptions = {};
// MaxTimeMS
var maxTimeMS = null;
// Get the promiseLibrary
var promiseLibrary = options.promiseLibrary || Promise;
... | [
"function",
"(",
"bson",
",",
"ns",
",",
"cmd",
",",
"options",
",",
"topology",
",",
"topologyOptions",
")",
"{",
"CoreCursor",
".",
"apply",
"(",
"this",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
")... | Namespace provided by the browser.
@external Readable
Creates a new Command Cursor instance (INTERNAL TYPE, do not instantiate directly)
@class CommandCursor
@extends external:Readable
@fires CommandCursor#data
@fires CommandCursor#end
@fires CommandCursor#close
@fires CommandCursor#readable
@return {CommandCursor} a... | [
"Namespace",
"provided",
"by",
"the",
"browser",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/command_cursor.js#L57-L96 | |
6,494 | mongodb/node-mongodb-native | lib/gridfs/grid_store.js | function(self, callback) {
// Calcuate the length
var mongoObject = {
_id: self.fileId,
filename: self.filename,
contentType: self.contentType,
length: self.position ? self.position : 0,
chunkSize: self.chunkSize,
uploadDate: self.uploadDate,
aliases: self.aliases,
metadata: self.met... | javascript | function(self, callback) {
// Calcuate the length
var mongoObject = {
_id: self.fileId,
filename: self.filename,
contentType: self.contentType,
length: self.position ? self.position : 0,
chunkSize: self.chunkSize,
uploadDate: self.uploadDate,
aliases: self.aliases,
metadata: self.met... | [
"function",
"(",
"self",
",",
"callback",
")",
"{",
"// Calcuate the length",
"var",
"mongoObject",
"=",
"{",
"_id",
":",
"self",
".",
"fileId",
",",
"filename",
":",
"self",
".",
"filename",
",",
"contentType",
":",
"self",
".",
"contentType",
",",
"lengt... | Creates a mongoDB object representation of this object.
<pre><code>
{
'_id' : , // {number} id for this file
'filename' : , // {string} name for this file
'contentType' : , // {string} mime type for this file
'length' : , // {number} size of this file?
'chunksize' : , // {number} chunk size used by this file
'uploadDa... | [
"Creates",
"a",
"mongoDB",
"object",
"representation",
"of",
"this",
"object",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs/grid_store.js#L1155-L1175 | |
6,495 | mongodb/node-mongodb-native | lib/gridfs/grid_store.js | function(self, chunkNumber, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || self.writeConcern;
options.readPreference = self.readPreference;
// Get the nth chunk
self
.chunkCollection()
.findOne({ files_id: self.fileId, n: c... | javascript | function(self, chunkNumber, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || self.writeConcern;
options.readPreference = self.readPreference;
// Get the nth chunk
self
.chunkCollection()
.findOne({ files_id: self.fileId, n: c... | [
"function",
"(",
"self",
",",
"chunkNumber",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"options",
"=",
"options",
"||",... | Gets the nth chunk of this file.
@ignore | [
"Gets",
"the",
"nth",
"chunk",
"of",
"this",
"file",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs/grid_store.js#L1181-L1198 | |
6,496 | mongodb/node-mongodb-native | lib/gridfs/grid_store.js | function(self, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || self.writeConcern;
if (self.fileId != null) {
self.chunkCollection().remove({ files_id: self.fileId }, options, function(err) {
if (err) return callback(err, fals... | javascript | function(self, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || self.writeConcern;
if (self.fileId != null) {
self.chunkCollection().remove({ files_id: self.fileId }, options, function(err) {
if (err) return callback(err, fals... | [
"function",
"(",
"self",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"options",
"=",
"options",
"||",
"self",
".",
"wri... | Deletes all the chunks of this file in the database.
@ignore | [
"Deletes",
"all",
"the",
"chunks",
"of",
"this",
"file",
"in",
"the",
"database",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs/grid_store.js#L1212-L1228 | |
6,497 | mongodb/node-mongodb-native | lib/gridfs-stream/download.js | GridFSBucketReadStream | function GridFSBucketReadStream(chunks, files, readPreference, filter, options) {
this.s = {
bytesRead: 0,
chunks: chunks,
cursor: null,
expected: 0,
files: files,
filter: filter,
init: false,
expectedEnd: 0,
file: null,
options: options,
readPreference: readPreference
};... | javascript | function GridFSBucketReadStream(chunks, files, readPreference, filter, options) {
this.s = {
bytesRead: 0,
chunks: chunks,
cursor: null,
expected: 0,
files: files,
filter: filter,
init: false,
expectedEnd: 0,
file: null,
options: options,
readPreference: readPreference
};... | [
"function",
"GridFSBucketReadStream",
"(",
"chunks",
",",
"files",
",",
"readPreference",
",",
"filter",
",",
"options",
")",
"{",
"this",
".",
"s",
"=",
"{",
"bytesRead",
":",
"0",
",",
"chunks",
":",
"chunks",
",",
"cursor",
":",
"null",
",",
"expected... | A readable stream that enables you to read buffers from GridFS.
Do not instantiate this class directly. Use `openDownloadStream()` instead.
@class
@param {Collection} chunks Handle for chunks collection
@param {Collection} files Handle for files collection
@param {Object} readPreference The read preference to use
@pa... | [
"A",
"readable",
"stream",
"that",
"enables",
"you",
"to",
"read",
"buffers",
"from",
"GridFS",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs-stream/download.js#L28-L44 |
6,498 | mongodb/node-mongodb-native | lib/operations/admin_ops.js | replSetGetStatus | function replSetGetStatus(admin, options, callback) {
executeDbAdminCommand(admin.s.db, { replSetGetStatus: 1 }, options, callback);
} | javascript | function replSetGetStatus(admin, options, callback) {
executeDbAdminCommand(admin.s.db, { replSetGetStatus: 1 }, options, callback);
} | [
"function",
"replSetGetStatus",
"(",
"admin",
",",
"options",
",",
"callback",
")",
"{",
"executeDbAdminCommand",
"(",
"admin",
".",
"s",
".",
"db",
",",
"{",
"replSetGetStatus",
":",
"1",
"}",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Get ReplicaSet status
@param {Admin} a collection instance.
@param {Object} [options] Optional settings. See Admin.prototype.replSetGetStatus for a list of options.
@param {Admin~resultCallback} [callback] The command result callback. | [
"Get",
"ReplicaSet",
"status"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/admin_ops.js#L13-L15 |
6,499 | mongodb/node-mongodb-native | lib/operations/admin_ops.js | serverStatus | function serverStatus(admin, options, callback) {
executeDbAdminCommand(admin.s.db, { serverStatus: 1 }, options, callback);
} | javascript | function serverStatus(admin, options, callback) {
executeDbAdminCommand(admin.s.db, { serverStatus: 1 }, options, callback);
} | [
"function",
"serverStatus",
"(",
"admin",
",",
"options",
",",
"callback",
")",
"{",
"executeDbAdminCommand",
"(",
"admin",
".",
"s",
".",
"db",
",",
"{",
"serverStatus",
":",
"1",
"}",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Retrieve this db's server status.
@param {Admin} a collection instance.
@param {Object} [options] Optional settings. See Admin.prototype.serverStatus for a list of options.
@param {Admin~resultCallback} [callback] The command result callback | [
"Retrieve",
"this",
"db",
"s",
"server",
"status",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/admin_ops.js#L24-L26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.