Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make "params" optional for all method #146

Merged
merged 1 commit into from
Apr 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class Service extends AdapterService {
* `find` service function for Objection.
* @param params
*/
_find (params) {
_find (params = {}) {
const find = (params, count, filters, query) => {
const q = params.objection || this.createQuery(params);
const groupByColumns = this.getGroupByColumns(q);
Expand Down Expand Up @@ -599,7 +599,7 @@ class Service extends AdapterService {
return result;
}

_get (id, params) {
_get (id, params = {}) {
// merge user query with the 'id' to get
const findQuery = Object.assign({}, { $and: [] }, params.query);
findQuery.$and.push(this.getIdsQuery(id));
Expand Down Expand Up @@ -695,7 +695,7 @@ class Service extends AdapterService {
* @param {object} data
* @param {object} params
*/
async _create (data, params) {
async _create (data, params = {}) {
const transaction = await this._createTransaction(params);
const q = this._createQuery(params);
let promise = q;
Expand Down Expand Up @@ -725,7 +725,7 @@ class Service extends AdapterService {
* @param data
* @param params
*/
_update (id, data, params) {
_update (id, data, params = {}) {
// NOTE : First fetch the item to update to account for user query
return this._get(id, params)
.then(() => {
Expand Down Expand Up @@ -790,7 +790,7 @@ class Service extends AdapterService {
* @param data
* @param params
*/
_patch (id, data, params) {
_patch (id, data, params = {}) {
let { filters, query } = this.filterQuery(params);

const allowedUpsert = this.mergeRelations(this.allowedUpsert, params.mergeAllowUpsert);
Expand Down Expand Up @@ -881,7 +881,7 @@ class Service extends AdapterService {
* @param id
* @param params
*/
_remove (id, params) {
_remove (id, params = {}) {
params.query = Object.assign({}, params.query);

// NOTE (EK): First fetch the record so that we can return
Expand Down