main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
5.8 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | module.exports = mongodb
|
---|
| 4 | mongodb.displayName = 'mongodb'
|
---|
| 5 | mongodb.aliases = []
|
---|
| 6 | function mongodb(Prism) {
|
---|
| 7 | ;(function (Prism) {
|
---|
| 8 | var operators = [
|
---|
| 9 | // query and projection
|
---|
| 10 | '$eq',
|
---|
| 11 | '$gt',
|
---|
| 12 | '$gte',
|
---|
| 13 | '$in',
|
---|
| 14 | '$lt',
|
---|
| 15 | '$lte',
|
---|
| 16 | '$ne',
|
---|
| 17 | '$nin',
|
---|
| 18 | '$and',
|
---|
| 19 | '$not',
|
---|
| 20 | '$nor',
|
---|
| 21 | '$or',
|
---|
| 22 | '$exists',
|
---|
| 23 | '$type',
|
---|
| 24 | '$expr',
|
---|
| 25 | '$jsonSchema',
|
---|
| 26 | '$mod',
|
---|
| 27 | '$regex',
|
---|
| 28 | '$text',
|
---|
| 29 | '$where',
|
---|
| 30 | '$geoIntersects',
|
---|
| 31 | '$geoWithin',
|
---|
| 32 | '$near',
|
---|
| 33 | '$nearSphere',
|
---|
| 34 | '$all',
|
---|
| 35 | '$elemMatch',
|
---|
| 36 | '$size',
|
---|
| 37 | '$bitsAllClear',
|
---|
| 38 | '$bitsAllSet',
|
---|
| 39 | '$bitsAnyClear',
|
---|
| 40 | '$bitsAnySet',
|
---|
| 41 | '$comment',
|
---|
| 42 | '$elemMatch',
|
---|
| 43 | '$meta',
|
---|
| 44 | '$slice', // update
|
---|
| 45 | '$currentDate',
|
---|
| 46 | '$inc',
|
---|
| 47 | '$min',
|
---|
| 48 | '$max',
|
---|
| 49 | '$mul',
|
---|
| 50 | '$rename',
|
---|
| 51 | '$set',
|
---|
| 52 | '$setOnInsert',
|
---|
| 53 | '$unset',
|
---|
| 54 | '$addToSet',
|
---|
| 55 | '$pop',
|
---|
| 56 | '$pull',
|
---|
| 57 | '$push',
|
---|
| 58 | '$pullAll',
|
---|
| 59 | '$each',
|
---|
| 60 | '$position',
|
---|
| 61 | '$slice',
|
---|
| 62 | '$sort',
|
---|
| 63 | '$bit', // aggregation pipeline stages
|
---|
| 64 | '$addFields',
|
---|
| 65 | '$bucket',
|
---|
| 66 | '$bucketAuto',
|
---|
| 67 | '$collStats',
|
---|
| 68 | '$count',
|
---|
| 69 | '$currentOp',
|
---|
| 70 | '$facet',
|
---|
| 71 | '$geoNear',
|
---|
| 72 | '$graphLookup',
|
---|
| 73 | '$group',
|
---|
| 74 | '$indexStats',
|
---|
| 75 | '$limit',
|
---|
| 76 | '$listLocalSessions',
|
---|
| 77 | '$listSessions',
|
---|
| 78 | '$lookup',
|
---|
| 79 | '$match',
|
---|
| 80 | '$merge',
|
---|
| 81 | '$out',
|
---|
| 82 | '$planCacheStats',
|
---|
| 83 | '$project',
|
---|
| 84 | '$redact',
|
---|
| 85 | '$replaceRoot',
|
---|
| 86 | '$replaceWith',
|
---|
| 87 | '$sample',
|
---|
| 88 | '$set',
|
---|
| 89 | '$skip',
|
---|
| 90 | '$sort',
|
---|
| 91 | '$sortByCount',
|
---|
| 92 | '$unionWith',
|
---|
| 93 | '$unset',
|
---|
| 94 | '$unwind',
|
---|
| 95 | '$setWindowFields', // aggregation pipeline operators
|
---|
| 96 | '$abs',
|
---|
| 97 | '$accumulator',
|
---|
| 98 | '$acos',
|
---|
| 99 | '$acosh',
|
---|
| 100 | '$add',
|
---|
| 101 | '$addToSet',
|
---|
| 102 | '$allElementsTrue',
|
---|
| 103 | '$and',
|
---|
| 104 | '$anyElementTrue',
|
---|
| 105 | '$arrayElemAt',
|
---|
| 106 | '$arrayToObject',
|
---|
| 107 | '$asin',
|
---|
| 108 | '$asinh',
|
---|
| 109 | '$atan',
|
---|
| 110 | '$atan2',
|
---|
| 111 | '$atanh',
|
---|
| 112 | '$avg',
|
---|
| 113 | '$binarySize',
|
---|
| 114 | '$bsonSize',
|
---|
| 115 | '$ceil',
|
---|
| 116 | '$cmp',
|
---|
| 117 | '$concat',
|
---|
| 118 | '$concatArrays',
|
---|
| 119 | '$cond',
|
---|
| 120 | '$convert',
|
---|
| 121 | '$cos',
|
---|
| 122 | '$dateFromParts',
|
---|
| 123 | '$dateToParts',
|
---|
| 124 | '$dateFromString',
|
---|
| 125 | '$dateToString',
|
---|
| 126 | '$dayOfMonth',
|
---|
| 127 | '$dayOfWeek',
|
---|
| 128 | '$dayOfYear',
|
---|
| 129 | '$degreesToRadians',
|
---|
| 130 | '$divide',
|
---|
| 131 | '$eq',
|
---|
| 132 | '$exp',
|
---|
| 133 | '$filter',
|
---|
| 134 | '$first',
|
---|
| 135 | '$floor',
|
---|
| 136 | '$function',
|
---|
| 137 | '$gt',
|
---|
| 138 | '$gte',
|
---|
| 139 | '$hour',
|
---|
| 140 | '$ifNull',
|
---|
| 141 | '$in',
|
---|
| 142 | '$indexOfArray',
|
---|
| 143 | '$indexOfBytes',
|
---|
| 144 | '$indexOfCP',
|
---|
| 145 | '$isArray',
|
---|
| 146 | '$isNumber',
|
---|
| 147 | '$isoDayOfWeek',
|
---|
| 148 | '$isoWeek',
|
---|
| 149 | '$isoWeekYear',
|
---|
| 150 | '$last',
|
---|
| 151 | '$last',
|
---|
| 152 | '$let',
|
---|
| 153 | '$literal',
|
---|
| 154 | '$ln',
|
---|
| 155 | '$log',
|
---|
| 156 | '$log10',
|
---|
| 157 | '$lt',
|
---|
| 158 | '$lte',
|
---|
| 159 | '$ltrim',
|
---|
| 160 | '$map',
|
---|
| 161 | '$max',
|
---|
| 162 | '$mergeObjects',
|
---|
| 163 | '$meta',
|
---|
| 164 | '$min',
|
---|
| 165 | '$millisecond',
|
---|
| 166 | '$minute',
|
---|
| 167 | '$mod',
|
---|
| 168 | '$month',
|
---|
| 169 | '$multiply',
|
---|
| 170 | '$ne',
|
---|
| 171 | '$not',
|
---|
| 172 | '$objectToArray',
|
---|
| 173 | '$or',
|
---|
| 174 | '$pow',
|
---|
| 175 | '$push',
|
---|
| 176 | '$radiansToDegrees',
|
---|
| 177 | '$range',
|
---|
| 178 | '$reduce',
|
---|
| 179 | '$regexFind',
|
---|
| 180 | '$regexFindAll',
|
---|
| 181 | '$regexMatch',
|
---|
| 182 | '$replaceOne',
|
---|
| 183 | '$replaceAll',
|
---|
| 184 | '$reverseArray',
|
---|
| 185 | '$round',
|
---|
| 186 | '$rtrim',
|
---|
| 187 | '$second',
|
---|
| 188 | '$setDifference',
|
---|
| 189 | '$setEquals',
|
---|
| 190 | '$setIntersection',
|
---|
| 191 | '$setIsSubset',
|
---|
| 192 | '$setUnion',
|
---|
| 193 | '$size',
|
---|
| 194 | '$sin',
|
---|
| 195 | '$slice',
|
---|
| 196 | '$split',
|
---|
| 197 | '$sqrt',
|
---|
| 198 | '$stdDevPop',
|
---|
| 199 | '$stdDevSamp',
|
---|
| 200 | '$strcasecmp',
|
---|
| 201 | '$strLenBytes',
|
---|
| 202 | '$strLenCP',
|
---|
| 203 | '$substr',
|
---|
| 204 | '$substrBytes',
|
---|
| 205 | '$substrCP',
|
---|
| 206 | '$subtract',
|
---|
| 207 | '$sum',
|
---|
| 208 | '$switch',
|
---|
| 209 | '$tan',
|
---|
| 210 | '$toBool',
|
---|
| 211 | '$toDate',
|
---|
| 212 | '$toDecimal',
|
---|
| 213 | '$toDouble',
|
---|
| 214 | '$toInt',
|
---|
| 215 | '$toLong',
|
---|
| 216 | '$toObjectId',
|
---|
| 217 | '$toString',
|
---|
| 218 | '$toLower',
|
---|
| 219 | '$toUpper',
|
---|
| 220 | '$trim',
|
---|
| 221 | '$trunc',
|
---|
| 222 | '$type',
|
---|
| 223 | '$week',
|
---|
| 224 | '$year',
|
---|
| 225 | '$zip',
|
---|
| 226 | '$count',
|
---|
| 227 | '$dateAdd',
|
---|
| 228 | '$dateDiff',
|
---|
| 229 | '$dateSubtract',
|
---|
| 230 | '$dateTrunc',
|
---|
| 231 | '$getField',
|
---|
| 232 | '$rand',
|
---|
| 233 | '$sampleRate',
|
---|
| 234 | '$setField',
|
---|
| 235 | '$unsetField', // aggregation pipeline query modifiers
|
---|
| 236 | '$comment',
|
---|
| 237 | '$explain',
|
---|
| 238 | '$hint',
|
---|
| 239 | '$max',
|
---|
| 240 | '$maxTimeMS',
|
---|
| 241 | '$min',
|
---|
| 242 | '$orderby',
|
---|
| 243 | '$query',
|
---|
| 244 | '$returnKey',
|
---|
| 245 | '$showDiskLoc',
|
---|
| 246 | '$natural'
|
---|
| 247 | ]
|
---|
| 248 | var builtinFunctions = [
|
---|
| 249 | 'ObjectId',
|
---|
| 250 | 'Code',
|
---|
| 251 | 'BinData',
|
---|
| 252 | 'DBRef',
|
---|
| 253 | 'Timestamp',
|
---|
| 254 | 'NumberLong',
|
---|
| 255 | 'NumberDecimal',
|
---|
| 256 | 'MaxKey',
|
---|
| 257 | 'MinKey',
|
---|
| 258 | 'RegExp',
|
---|
| 259 | 'ISODate',
|
---|
| 260 | 'UUID'
|
---|
| 261 | ]
|
---|
| 262 | operators = operators.map(function (operator) {
|
---|
| 263 | return operator.replace('$', '\\$')
|
---|
| 264 | })
|
---|
| 265 | var operatorsSource = '(?:' + operators.join('|') + ')\\b'
|
---|
| 266 | Prism.languages.mongodb = Prism.languages.extend('javascript', {})
|
---|
| 267 | Prism.languages.insertBefore('mongodb', 'string', {
|
---|
| 268 | property: {
|
---|
| 269 | pattern:
|
---|
| 270 | /(?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)(?=\s*:)/,
|
---|
| 271 | greedy: true,
|
---|
| 272 | inside: {
|
---|
| 273 | keyword: RegExp('^([\'"])?' + operatorsSource + '(?:\\1)?$')
|
---|
| 274 | }
|
---|
| 275 | }
|
---|
| 276 | })
|
---|
| 277 | Prism.languages.mongodb.string.inside = {
|
---|
| 278 | url: {
|
---|
| 279 | // url pattern
|
---|
| 280 | pattern:
|
---|
| 281 | /https?:\/\/[-\w@:%.+~#=]{1,256}\.[a-z0-9()]{1,6}\b[-\w()@:%+.~#?&/=]*/i,
|
---|
| 282 | greedy: true
|
---|
| 283 | },
|
---|
| 284 | entity: {
|
---|
| 285 | // ipv4
|
---|
| 286 | pattern:
|
---|
| 287 | /\b(?:(?:[01]?\d\d?|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d\d?|2[0-4]\d|25[0-5])\b/,
|
---|
| 288 | greedy: true
|
---|
| 289 | }
|
---|
| 290 | }
|
---|
| 291 | Prism.languages.insertBefore('mongodb', 'constant', {
|
---|
| 292 | builtin: {
|
---|
| 293 | pattern: RegExp('\\b(?:' + builtinFunctions.join('|') + ')\\b'),
|
---|
| 294 | alias: 'keyword'
|
---|
| 295 | }
|
---|
| 296 | })
|
---|
| 297 | })(Prism)
|
---|
| 298 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.