

- #Simple express middleware simple find replace filter Patch
- #Simple express middleware simple find replace filter full
Remember that the collection passed to addResource() must be an array (or array-like object), not an object. Turn on logging (with logging.enable()) to debug your rules.Ĭall the /_reset endpoint to reset your data. Form data ( Content-Type: application/x-www-form-urlencoded) are also supported.
#Simple express middleware simple find replace filter Patch
PATCH /example/:id - Extends the matching resource with the given object.ĭon't forget to set Content-Type: application/json in your requests. It looks for an ID in each element of the array to lookup the existing items in the collection. PATCH /example - Extends the matching resources using the given array of objects. Returns a 404 if no item with that ID exists. Returns the empty collection.ĭELETE /example/:id - Removes the matching resource from the collection. Returns a 404 if no item with that ID exists.ĭELETE /example - Empties the collection. PUT /example/:id - Replaces the matching resource with the passed JSON body. PUT /example - Replaces the entire collection with the passed JSON body. POST /example - Adds a new item with the passed JSON body. HEAD (anything) - Same as GET, but doesn't return the body. GET /example/:id - Returns a single item from the collection. Any other parameter will filter the collection using that parameter as the field name, and performing an exact string match against the value.sortBy and sortDir will sort the results by the top-level property specified in sortBy, in the direction specified by sortDir - either case-insensitive asc (the default), or desc for reversed sorting.Note: All values are converted to strings for matching. query or q parameters will perform a partial text search.
#Simple express middleware simple find replace filter full
Note: the returned total will remain the size of full collection.

offset (zero-based) and limit parameters will return only a subset of the collection.GET /example?params - Returns a filtered collection. Each item in the array should have the following pattern: ParamFilters - An array of filters used when filtering the collection during GET /path. The following properties can only be changed on the rule object after it is created. These options can also be changed in the rule object after it is created. sortDirParam - The name(s) to use for the direction parameter when sorting collection results (string or array of strings, default ).sortByParam - The name(s) to use for the field parameter when sorting collection results (string or array of strings, default ).queryParam - The name(s) to use for the query parameter when performing a collection text search (string or array of strings, default ).limitParam - The name(s) to use for the "limit" query parameter when retrieving a collection subset (string or array of strings, default limit).offsetParam - The name(s) to use for the "offset" query parameter when retrieving a collection subset (string or array of strings, default offset).countKey - The property name for the collection response (default total).collectionKey - The property name for the collection response (default items).If not specified, the library will use the id field, or the first field that ends in Id, or the first field. The collection argument should be the array of data that the endpoint begins with.

Note: The path cannot contain an :id placeholder that is reserved for use by the module. createServer ( app ) API addResource(path, collection, options)Īdds a new resource at the given path. addResource ( '/movies', movieCollection ) var app = connect ( ) mocks. addResource ( '/books', bookCollection ) mocks. Var connect = require ( 'connect' ) var http = require ( 'http' ) var createMocks = require ( 'mock-rest-middleware' ) var mocks = createMocks ( ) var bookCollection = var movieCollection = mocks.
