(body, defaultLimit)
| 162 | } |
| 163 | |
| 164 | static optionsFromBody(body, defaultLimit) { |
| 165 | const allowConstraints = [ |
| 166 | 'skip', |
| 167 | 'limit', |
| 168 | 'order', |
| 169 | 'count', |
| 170 | 'keys', |
| 171 | 'excludeKeys', |
| 172 | 'include', |
| 173 | 'includeAll', |
| 174 | 'redirectClassNameForKey', |
| 175 | 'where', |
| 176 | 'readPreference', |
| 177 | 'includeReadPreference', |
| 178 | 'subqueryReadPreference', |
| 179 | 'hint', |
| 180 | 'explain', |
| 181 | 'comment', |
| 182 | ]; |
| 183 | |
| 184 | for (const key of Object.keys(body)) { |
| 185 | if (allowConstraints.indexOf(key) === -1) { |
| 186 | throw new Parse.Error(Parse.Error.INVALID_QUERY, `Invalid parameter for query: ${key}`); |
| 187 | } |
| 188 | } |
| 189 | const options = {}; |
| 190 | if (body.skip) { |
| 191 | options.skip = Number(body.skip); |
| 192 | } |
| 193 | if (body.limit || body.limit === 0) { |
| 194 | options.limit = Number(body.limit); |
| 195 | } else { |
| 196 | options.limit = Number(defaultLimit); |
| 197 | } |
| 198 | if (body.order) { |
| 199 | options.order = String(body.order); |
| 200 | } |
| 201 | if (body.count) { |
| 202 | options.count = true; |
| 203 | } |
| 204 | if (body.keys != null) { |
| 205 | options.keys = String(body.keys); |
| 206 | } |
| 207 | if (body.excludeKeys != null) { |
| 208 | options.excludeKeys = String(body.excludeKeys); |
| 209 | } |
| 210 | if (body.include != null) { |
| 211 | options.include = String(body.include); |
| 212 | } |
| 213 | if (body.includeAll) { |
| 214 | options.includeAll = true; |
| 215 | } |
| 216 | if (typeof body.readPreference === 'string') { |
| 217 | options.readPreference = body.readPreference; |
| 218 | } |
| 219 | if (typeof body.includeReadPreference === 'string') { |
| 220 | options.includeReadPreference = body.includeReadPreference; |
| 221 | } |
no outgoing calls
no test coverage detected