(
className: string,
query: any,
{
skip,
limit,
acl,
sort = {},
count,
keys,
op,
distinct,
pipeline,
readPreference,
hint,
caseInsensitive = false,
explain,
comment,
rawValues,
rawFieldNames,
}: any = {},
auth: any = {},
validSchemaController: SchemaController.SchemaController
)
| 1252 | // anything about users, ideally. Then, improve the format of the ACL |
| 1253 | // arg to work like the others. |
| 1254 | find( |
| 1255 | className: string, |
| 1256 | query: any, |
| 1257 | { |
| 1258 | skip, |
| 1259 | limit, |
| 1260 | acl, |
| 1261 | sort = {}, |
| 1262 | count, |
| 1263 | keys, |
| 1264 | op, |
| 1265 | distinct, |
| 1266 | pipeline, |
| 1267 | readPreference, |
| 1268 | hint, |
| 1269 | caseInsensitive = false, |
| 1270 | explain, |
| 1271 | comment, |
| 1272 | rawValues, |
| 1273 | rawFieldNames, |
| 1274 | }: any = {}, |
| 1275 | auth: any = {}, |
| 1276 | validSchemaController: SchemaController.SchemaController |
| 1277 | ): Promise<any> { |
| 1278 | const isMaintenance = auth.isMaintenance; |
| 1279 | const isMaster = acl === undefined || isMaintenance; |
| 1280 | const aclGroup = acl || []; |
| 1281 | op = |
| 1282 | op || (typeof query.objectId == 'string' && Object.keys(query).length === 1 ? 'get' : 'find'); |
| 1283 | // Count operation if counting |
| 1284 | op = count === true ? 'count' : op; |
| 1285 | |
| 1286 | let classExists = true; |
| 1287 | return this.loadSchemaIfNeeded(validSchemaController).then(schemaController => { |
| 1288 | //Allow volatile classes if querying with Master (for _PushStatus) |
| 1289 | //TODO: Move volatile classes concept into mongo adapter, postgres adapter shouldn't care |
| 1290 | //that api.parse.com breaks when _PushStatus exists in mongo. |
| 1291 | return schemaController |
| 1292 | .getOneSchema(className, isMaster) |
| 1293 | .catch(error => { |
| 1294 | // Behavior for non-existent classes is kinda weird on Parse.com. Probably doesn't matter too much. |
| 1295 | // For now, pretend the class exists but has no objects, |
| 1296 | if (error === undefined) { |
| 1297 | classExists = false; |
| 1298 | return { fields: {} }; |
| 1299 | } |
| 1300 | throw error; |
| 1301 | }) |
| 1302 | .then(schema => { |
| 1303 | // Parse.com treats queries on _created_at and _updated_at as if they were queries on createdAt and updatedAt, |
| 1304 | // so duplicate that behavior here. If both are specified, the correct behavior to match Parse.com is to |
| 1305 | // use the one that appears first in the sort list. |
| 1306 | if (sort._created_at) { |
| 1307 | sort.createdAt = sort._created_at; |
| 1308 | delete sort._created_at; |
| 1309 | } |
| 1310 | if (sort._updated_at) { |
| 1311 | sort.updatedAt = sort._updated_at; |
nothing calls this directly
no test coverage detected