Back to Medusa

MedusaRequest

www/apps/resources/references/medusa/interfaces/medusa.MedusaRequest/page.mdx

2.15.311.6 KB
Original Source

import { TypeList } from "docs-ui"

MedusaRequest

Type parameters

<TypeList types={[{"name":"Body","type":"object","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"QueryFields","type":"object","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="MedusaRequest"/>

Properties

<TypeList types={[{"name":"validatedBody","type":"Body","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"validatedQuery","type":"RequestQueryFields & QueryFields","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"string","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"number","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"number","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"string","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with -.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"with_deleted","type":"boolean","description":"Whether to include deleted records in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"allowedProperties","type":"string[]","description":"TODO: shouldn't this correspond to returnable fields instead of allowed fields? also it is used by the cleanResponseData util","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"listConfig","type":"FindConfig<unknown>","description":"An object containing the select, relation, skip, take and order to be used with medusa internal services","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"select","type":"(keyof Entity \| string & object)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"skip","type":"null \| number","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"take","type":"null \| number","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"relations","type":"string[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.\n\nYou can only retrieve data models defined in the same module. To retrieve linked data models\nfrom other modules, use Query instead.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"FindConfigOrder","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be ASC\nto sort retrieved records in an ascending order, or DESC to sort retrieved records in a descending order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"withDeleted","type":"boolean","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the\nSoftDeletableEntity class.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"filters","type":"Record<string, any>","description":"Enable ORM specific defined filters","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Record<string, any>","description":"Enable ORM specific defined options","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"retrieveConfig","type":"FindConfig<unknown>","description":"An object containing the select, relation to be used with medusa internal services","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"select","type":"(keyof Entity \| string & object)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"skip","type":"null \| number","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"take","type":"null \| number","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"relations","type":"string[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.\n\nYou can only retrieve data models defined in the same module. To retrieve linked data models\nfrom other modules, use Query instead.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"FindConfigOrder","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be ASC\nto sort retrieved records in an ascending order, or DESC to sort retrieved records in a descending order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"withDeleted","type":"boolean","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the\nSoftDeletableEntity class.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"filters","type":"Record<string, any>","description":"Enable ORM specific defined filters","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Record<string, any>","description":"Enable ORM specific defined options","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"queryConfig","type":"object","description":"An object containing fields and variables to be used with the remoteQuery","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"string[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"pagination","type":"object","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"withDeleted","type":"boolean","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}],"since":"2.2.0"},{"name":"remoteQueryConfig","type":"object","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"string[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"pagination","type":"object","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"withDeleted","type":"boolean","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}],"deprecated":{"is_deprecated":true,"description":"Use queryConfig instead."}},{"name":"filterableFields","type":"QueryFields","description":"An object containing the fields that are filterable e.g { id: Any<String> }","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"errors","type":"string[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"scope","type":"MedusaContainer","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"includes","type":"Record<string, boolean>","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allowed","type":"string[]","description":"An array of fields and relations that are allowed to be queried, this can be set by the\nconsumer as part of a middleware and it will take precedence over the req.allowed set\nby the api","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"session","type":"any","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rawBody","type":"any","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requestId","type":"string","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"restrictedFields","type":"RestrictedFields","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"#private","type":"any","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"pricingContext","type":"MedusaPricingContext","description":"An object that carries the context that is used to calculate prices for variants","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"region_id","type":"string","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"string","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"string","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"object","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"context","type":"Record<string, any>","description":"A generic context object that can be used across the request lifecycle","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"additionalDataValidator","type":"ZodOptional<ZodNullable<ZodObject<any, any>>>","description":"Custom validator to validate the additional_data property in\nrequests that allows for additional\_data","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"locale","type":"string","description":"The locale for the current request, resolved from:\n1. Query parameter ?locale=\n2. x-medusa-locale header\n3. Store's default locale","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"user","type":"object","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"customer_id","type":"string","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"userId","type":"string","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="MedusaRequest"/>