Skip to content

Commit 3c1311f

Browse files
committed
Merge pull request #331 from ksaldana1/es6-refactor
Implemented ES6 default parameters in ExportAdapter & RestQuery
2 parents 67959e5 + 4f128d7 commit 3c1311f

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/ExportAdapter.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ var transform = require('./transform');
1010

1111
// options can contain:
1212
// collectionPrefix: the string to put in front of every collection name.
13-
function ExportAdapter(mongoURI, options) {
13+
function ExportAdapter(mongoURI, options = {}) {
1414
this.mongoURI = mongoURI;
15-
options = options || {};
1615

1716
this.collectionPrefix = options.collectionPrefix;
1817

@@ -63,8 +62,7 @@ function returnsTrue() {
6362
// Returns a promise for a schema object.
6463
// If we are provided a acceptor, then we run it on the schema.
6564
// If the schema isn't accepted, we reload it at most once.
66-
ExportAdapter.prototype.loadSchema = function(acceptor) {
67-
acceptor = acceptor || returnsTrue;
65+
ExportAdapter.prototype.loadSchema = function(acceptor = returnsTrue) {
6866

6967
if (!this.schemaPromise) {
7068
this.schemaPromise = this.collection('_SCHEMA').then((coll) => {
@@ -277,8 +275,7 @@ ExportAdapter.prototype.removeRelation = function(key, fromClassName,
277275
// acl: a list of strings. If the object to be updated has an ACL,
278276
// one of the provided strings must provide the caller with
279277
// write permissions.
280-
ExportAdapter.prototype.destroy = function(className, query, options) {
281-
options = options || {};
278+
ExportAdapter.prototype.destroy = function(className, query, options = {}) {
282279
var isMaster = !('acl' in options);
283280
var aclGroup = options.acl || [];
284281

@@ -346,8 +343,7 @@ ExportAdapter.prototype.create = function(className, object, options) {
346343
// This should only be used for testing - use 'find' for normal code
347344
// to avoid Mongo-format dependencies.
348345
// Returns a promise that resolves to a list of items.
349-
ExportAdapter.prototype.mongoFind = function(className, query, options) {
350-
options = options || {};
346+
ExportAdapter.prototype.mongoFind = function(className, query, options = {}) {
351347
return this.collection(className).then((coll) => {
352348
return coll.find(query, options).toArray();
353349
});
@@ -503,8 +499,7 @@ ExportAdapter.prototype.smartFind = function(coll, where, options) {
503499
// TODO: make userIds not needed here. The db adapter shouldn't know
504500
// anything about users, ideally. Then, improve the format of the ACL
505501
// arg to work like the others.
506-
ExportAdapter.prototype.find = function(className, query, options) {
507-
options = options || {};
502+
ExportAdapter.prototype.find = function(className, query, options = {}) {
508503
var mongoOptions = {};
509504
if (options.skip) {
510505
mongoOptions.skip = options.skip;

src/RestQuery.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ var Parse = require('parse/node').Parse;
1111
// include
1212
// keys
1313
// redirectClassNameForKey
14-
function RestQuery(config, auth, className, restWhere, restOptions) {
15-
restOptions = restOptions || {};
14+
function RestQuery(config, auth, className, restWhere = {}, restOptions = {}) {
1615

1716
this.config = config;
1817
this.auth = auth;
1918
this.className = className;
20-
this.restWhere = restWhere || {};
19+
this.restWhere = restWhere;
2120
this.response = null;
2221

2322
this.findOptions = {};

0 commit comments

Comments
 (0)