* Use to perform a query on a class. It will run security checks and triggers. * @param options * @param options.method {RestQuery.Method} The type of query to perform * @param options.config {ParseServerConfiguration} The server configuration * @param options.auth {Auth} The auth object for the
({
method,
config,
auth,
className,
restWhere = {},
restOptions = {},
clientSDK,
runAfterFind = true,
runBeforeFind = true,
context,
})
| 38 | * @returns {Promise<_UnsafeRestQuery>} A promise that is resolved with the _UnsafeRestQuery object |
| 39 | */ |
| 40 | async function RestQuery({ |
| 41 | method, |
| 42 | config, |
| 43 | auth, |
| 44 | className, |
| 45 | restWhere = {}, |
| 46 | restOptions = {}, |
| 47 | clientSDK, |
| 48 | runAfterFind = true, |
| 49 | runBeforeFind = true, |
| 50 | context, |
| 51 | }) { |
| 52 | if (![RestQuery.Method.find, RestQuery.Method.get].includes(method)) { |
| 53 | throw new Parse.Error(Parse.Error.INVALID_QUERY, 'bad query type'); |
| 54 | } |
| 55 | const isGet = method === RestQuery.Method.get; |
| 56 | enforceRoleSecurity(method, className, auth, config); |
| 57 | const result = runBeforeFind |
| 58 | ? await triggers.maybeRunQueryTrigger( |
| 59 | triggers.Types.beforeFind, |
| 60 | className, |
| 61 | restWhere, |
| 62 | restOptions, |
| 63 | config, |
| 64 | auth, |
| 65 | context, |
| 66 | isGet |
| 67 | ) |
| 68 | : Promise.resolve({ restWhere, restOptions }); |
| 69 | |
| 70 | return new _UnsafeRestQuery( |
| 71 | config, |
| 72 | auth, |
| 73 | className, |
| 74 | result.restWhere || restWhere, |
| 75 | result.restOptions || restOptions, |
| 76 | clientSDK, |
| 77 | runAfterFind, |
| 78 | context, |
| 79 | isGet |
| 80 | ); |
| 81 | } |
| 82 | |
| 83 | RestQuery.Method = Object.freeze({ |
| 84 | get: 'get', |
no test coverage detected