mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Fixed indenting for Bookshelf sanitize plugin JSDoc
no issue - the indentation copied over incorrectly when I moved the code between files
This commit is contained in:
parent
44a6e399dd
commit
a2b3568956
1 changed files with 31 additions and 31 deletions
|
@ -52,12 +52,12 @@ module.exports = function (Bookshelf) {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters potentially unsafe model attributes, so you can pass them to Bookshelf / Knex.
|
* Filters potentially unsafe model attributes, so you can pass them to Bookshelf / Knex.
|
||||||
* This filter should be called before each insert/update operation.
|
* This filter should be called before each insert/update operation.
|
||||||
*
|
*
|
||||||
* @param {Object} data Has keys representing the model's attributes/fields in the database.
|
* @param {Object} data Has keys representing the model's attributes/fields in the database.
|
||||||
* @return {Object} The filtered results of the passed in data, containing only what's allowed in the schema.
|
* @return {Object} The filtered results of the passed in data, containing only what's allowed in the schema.
|
||||||
*/
|
*/
|
||||||
filterData: function filterData(data) {
|
filterData: function filterData(data) {
|
||||||
const permittedAttributes = this.prototype.permittedAttributes();
|
const permittedAttributes = this.prototype.permittedAttributes();
|
||||||
const filteredData = _.pick(data, permittedAttributes);
|
const filteredData = _.pick(data, permittedAttributes);
|
||||||
|
@ -67,26 +67,26 @@ module.exports = function (Bookshelf) {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `sanitizeData` ensures that client data is in the correct format for further operations.
|
* `sanitizeData` ensures that client data is in the correct format for further operations.
|
||||||
*
|
*
|
||||||
* Dates:
|
* Dates:
|
||||||
* - client dates are sent as ISO 8601 format (moment(..).format())
|
* - client dates are sent as ISO 8601 format (moment(..).format())
|
||||||
* - server dates are in JS Date format
|
* - server dates are in JS Date format
|
||||||
* >> when bookshelf fetches data from the database, all dates are in JS Dates
|
* >> when bookshelf fetches data from the database, all dates are in JS Dates
|
||||||
* >> see `parse`
|
* >> see `parse`
|
||||||
* - Bookshelf updates the model with the new client data via the `set` function
|
* - Bookshelf updates the model with the new client data via the `set` function
|
||||||
* - Bookshelf uses a simple `isEqual` function from lodash to detect real changes
|
* - Bookshelf uses a simple `isEqual` function from lodash to detect real changes
|
||||||
* - .previous(attr) and .get(attr) returns false obviously
|
* - .previous(attr) and .get(attr) returns false obviously
|
||||||
* - internally we use our `hasDateChanged` if we have to compare previous dates
|
* - internally we use our `hasDateChanged` if we have to compare previous dates
|
||||||
* - but Bookshelf is not in our control for this case
|
* - but Bookshelf is not in our control for this case
|
||||||
*
|
*
|
||||||
* @IMPORTANT
|
* @IMPORTANT
|
||||||
* Before the new client data get's inserted again, the dates get's re-transformed into
|
* Before the new client data get's inserted again, the dates get's re-transformed into
|
||||||
* proper strings, see `format`.
|
* proper strings, see `format`.
|
||||||
*
|
*
|
||||||
* @IMPORTANT
|
* @IMPORTANT
|
||||||
* Sanitize relations.
|
* Sanitize relations.
|
||||||
*/
|
*/
|
||||||
sanitizeData: function sanitizeData(data) {
|
sanitizeData: function sanitizeData(data) {
|
||||||
const tableName = _.result(this.prototype, 'tableName');
|
const tableName = _.result(this.prototype, 'tableName');
|
||||||
let date;
|
let date;
|
||||||
|
@ -145,11 +145,11 @@ module.exports = function (Bookshelf) {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters potentially unsafe `options` in a model method's arguments, so you can pass them to Bookshelf / Knex.
|
* Filters potentially unsafe `options` in a model method's arguments, so you can pass them to Bookshelf / Knex.
|
||||||
* @param {Object} unfilteredOptions Represents options to filter in order to be passed to the Bookshelf query.
|
* @param {Object} unfilteredOptions Represents options to filter in order to be passed to the Bookshelf query.
|
||||||
* @param {String} methodName The name of the method to check valid options for.
|
* @param {String} methodName The name of the method to check valid options for.
|
||||||
* @return {Object} The filtered results of `options`.
|
* @return {Object} The filtered results of `options`.
|
||||||
*/
|
*/
|
||||||
filterOptions: function filterOptions(unfilteredOptions, methodName, filterConfig) {
|
filterOptions: function filterOptions(unfilteredOptions, methodName, filterConfig) {
|
||||||
unfilteredOptions = unfilteredOptions || {};
|
unfilteredOptions = unfilteredOptions || {};
|
||||||
filterConfig = filterConfig || {};
|
filterConfig = filterConfig || {};
|
||||||
|
|
Loading…
Add table
Reference in a new issue