[d24f17c] | 1 | (function (Prism) {
|
---|
| 2 |
|
---|
| 3 | var operators = [
|
---|
| 4 | // query and projection
|
---|
| 5 | '$eq', '$gt', '$gte', '$in', '$lt', '$lte', '$ne', '$nin', '$and', '$not', '$nor', '$or',
|
---|
| 6 | '$exists', '$type', '$expr', '$jsonSchema', '$mod', '$regex', '$text', '$where', '$geoIntersects',
|
---|
| 7 | '$geoWithin', '$near', '$nearSphere', '$all', '$elemMatch', '$size', '$bitsAllClear', '$bitsAllSet',
|
---|
| 8 | '$bitsAnyClear', '$bitsAnySet', '$comment', '$elemMatch', '$meta', '$slice',
|
---|
| 9 |
|
---|
| 10 | // update
|
---|
| 11 | '$currentDate', '$inc', '$min', '$max', '$mul', '$rename', '$set', '$setOnInsert', '$unset',
|
---|
| 12 | '$addToSet', '$pop', '$pull', '$push', '$pullAll', '$each', '$position', '$slice', '$sort', '$bit',
|
---|
| 13 |
|
---|
| 14 | // aggregation pipeline stages
|
---|
| 15 | '$addFields', '$bucket', '$bucketAuto', '$collStats', '$count', '$currentOp', '$facet', '$geoNear',
|
---|
| 16 | '$graphLookup', '$group', '$indexStats', '$limit', '$listLocalSessions', '$listSessions', '$lookup',
|
---|
| 17 | '$match', '$merge', '$out', '$planCacheStats', '$project', '$redact', '$replaceRoot', '$replaceWith',
|
---|
| 18 | '$sample', '$set', '$skip', '$sort', '$sortByCount', '$unionWith', '$unset', '$unwind', '$setWindowFields',
|
---|
| 19 |
|
---|
| 20 | // aggregation pipeline operators
|
---|
| 21 | '$abs', '$accumulator', '$acos', '$acosh', '$add', '$addToSet', '$allElementsTrue', '$and',
|
---|
| 22 | '$anyElementTrue', '$arrayElemAt', '$arrayToObject', '$asin', '$asinh', '$atan', '$atan2',
|
---|
| 23 | '$atanh', '$avg', '$binarySize', '$bsonSize', '$ceil', '$cmp', '$concat', '$concatArrays', '$cond',
|
---|
| 24 | '$convert', '$cos', '$dateFromParts', '$dateToParts', '$dateFromString', '$dateToString', '$dayOfMonth',
|
---|
| 25 | '$dayOfWeek', '$dayOfYear', '$degreesToRadians', '$divide', '$eq', '$exp', '$filter', '$first',
|
---|
| 26 | '$floor', '$function', '$gt', '$gte', '$hour', '$ifNull', '$in', '$indexOfArray', '$indexOfBytes',
|
---|
| 27 | '$indexOfCP', '$isArray', '$isNumber', '$isoDayOfWeek', '$isoWeek', '$isoWeekYear', '$last',
|
---|
| 28 | '$last', '$let', '$literal', '$ln', '$log', '$log10', '$lt', '$lte', '$ltrim', '$map', '$max',
|
---|
| 29 | '$mergeObjects', '$meta', '$min', '$millisecond', '$minute', '$mod', '$month', '$multiply', '$ne',
|
---|
| 30 | '$not', '$objectToArray', '$or', '$pow', '$push', '$radiansToDegrees', '$range', '$reduce',
|
---|
| 31 | '$regexFind', '$regexFindAll', '$regexMatch', '$replaceOne', '$replaceAll', '$reverseArray', '$round',
|
---|
| 32 | '$rtrim', '$second', '$setDifference', '$setEquals', '$setIntersection', '$setIsSubset', '$setUnion',
|
---|
| 33 | '$size', '$sin', '$slice', '$split', '$sqrt', '$stdDevPop', '$stdDevSamp', '$strcasecmp', '$strLenBytes',
|
---|
| 34 | '$strLenCP', '$substr', '$substrBytes', '$substrCP', '$subtract', '$sum', '$switch', '$tan',
|
---|
| 35 | '$toBool', '$toDate', '$toDecimal', '$toDouble', '$toInt', '$toLong', '$toObjectId', '$toString',
|
---|
| 36 | '$toLower', '$toUpper', '$trim', '$trunc', '$type', '$week', '$year', '$zip', '$count', '$dateAdd',
|
---|
| 37 | '$dateDiff', '$dateSubtract', '$dateTrunc', '$getField', '$rand', '$sampleRate', '$setField', '$unsetField',
|
---|
| 38 |
|
---|
| 39 | // aggregation pipeline query modifiers
|
---|
| 40 | '$comment', '$explain', '$hint', '$max', '$maxTimeMS', '$min', '$orderby', '$query',
|
---|
| 41 | '$returnKey', '$showDiskLoc', '$natural',
|
---|
| 42 | ];
|
---|
| 43 |
|
---|
| 44 | var builtinFunctions = [
|
---|
| 45 | 'ObjectId',
|
---|
| 46 | 'Code',
|
---|
| 47 | 'BinData',
|
---|
| 48 | 'DBRef',
|
---|
| 49 | 'Timestamp',
|
---|
| 50 | 'NumberLong',
|
---|
| 51 | 'NumberDecimal',
|
---|
| 52 | 'MaxKey',
|
---|
| 53 | 'MinKey',
|
---|
| 54 | 'RegExp',
|
---|
| 55 | 'ISODate',
|
---|
| 56 | 'UUID',
|
---|
| 57 | ];
|
---|
| 58 |
|
---|
| 59 | operators = operators.map(function (operator) {
|
---|
| 60 | return operator.replace('$', '\\$');
|
---|
| 61 | });
|
---|
| 62 |
|
---|
| 63 | var operatorsSource = '(?:' + operators.join('|') + ')\\b';
|
---|
| 64 |
|
---|
| 65 | Prism.languages.mongodb = Prism.languages.extend('javascript', {});
|
---|
| 66 |
|
---|
| 67 | Prism.languages.insertBefore('mongodb', 'string', {
|
---|
| 68 | 'property': {
|
---|
| 69 | pattern: /(?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)(?=\s*:)/,
|
---|
| 70 | greedy: true,
|
---|
| 71 | inside: {
|
---|
| 72 | 'keyword': RegExp('^([\'"])?' + operatorsSource + '(?:\\1)?$')
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
| 75 | });
|
---|
| 76 |
|
---|
| 77 | Prism.languages.mongodb.string.inside = {
|
---|
| 78 | url: {
|
---|
| 79 | // url pattern
|
---|
| 80 | pattern: /https?:\/\/[-\w@:%.+~#=]{1,256}\.[a-z0-9()]{1,6}\b[-\w()@:%+.~#?&/=]*/i,
|
---|
| 81 | greedy: true
|
---|
| 82 | },
|
---|
| 83 | entity: {
|
---|
| 84 | // ipv4
|
---|
| 85 | pattern: /\b(?:(?:[01]?\d\d?|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d\d?|2[0-4]\d|25[0-5])\b/,
|
---|
| 86 | greedy: true
|
---|
| 87 | }
|
---|
| 88 | };
|
---|
| 89 |
|
---|
| 90 | Prism.languages.insertBefore('mongodb', 'constant', {
|
---|
| 91 | 'builtin': {
|
---|
| 92 | pattern: RegExp('\\b(?:' + builtinFunctions.join('|') + ')\\b'),
|
---|
| 93 | alias: 'keyword'
|
---|
| 94 | }
|
---|
| 95 | });
|
---|
| 96 |
|
---|
| 97 | }(Prism));
|
---|