Implemented ES6 default parameters where valid in ExportAdapter and RestQuery
This commit is contained in:
@@ -10,9 +10,8 @@ var transform = require('./transform');
|
|||||||
|
|
||||||
// options can contain:
|
// options can contain:
|
||||||
// collectionPrefix: the string to put in front of every collection name.
|
// collectionPrefix: the string to put in front of every collection name.
|
||||||
function ExportAdapter(mongoURI, options) {
|
function ExportAdapter(mongoURI, options = {}) {
|
||||||
this.mongoURI = mongoURI;
|
this.mongoURI = mongoURI;
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
this.collectionPrefix = options.collectionPrefix;
|
this.collectionPrefix = options.collectionPrefix;
|
||||||
|
|
||||||
@@ -63,8 +62,7 @@ function returnsTrue() {
|
|||||||
// Returns a promise for a schema object.
|
// Returns a promise for a schema object.
|
||||||
// If we are provided a acceptor, then we run it on the schema.
|
// If we are provided a acceptor, then we run it on the schema.
|
||||||
// If the schema isn't accepted, we reload it at most once.
|
// If the schema isn't accepted, we reload it at most once.
|
||||||
ExportAdapter.prototype.loadSchema = function(acceptor) {
|
ExportAdapter.prototype.loadSchema = function(acceptor = returnsTrue) {
|
||||||
acceptor = acceptor || returnsTrue;
|
|
||||||
|
|
||||||
if (!this.schemaPromise) {
|
if (!this.schemaPromise) {
|
||||||
this.schemaPromise = this.collection('_SCHEMA').then((coll) => {
|
this.schemaPromise = this.collection('_SCHEMA').then((coll) => {
|
||||||
@@ -277,8 +275,7 @@ ExportAdapter.prototype.removeRelation = function(key, fromClassName,
|
|||||||
// acl: a list of strings. If the object to be updated has an ACL,
|
// acl: a list of strings. If the object to be updated has an ACL,
|
||||||
// one of the provided strings must provide the caller with
|
// one of the provided strings must provide the caller with
|
||||||
// write permissions.
|
// write permissions.
|
||||||
ExportAdapter.prototype.destroy = function(className, query, options) {
|
ExportAdapter.prototype.destroy = function(className, query, options = {}) {
|
||||||
options = options || {};
|
|
||||||
var isMaster = !('acl' in options);
|
var isMaster = !('acl' in options);
|
||||||
var aclGroup = options.acl || [];
|
var aclGroup = options.acl || [];
|
||||||
|
|
||||||
@@ -346,8 +343,7 @@ ExportAdapter.prototype.create = function(className, object, options) {
|
|||||||
// This should only be used for testing - use 'find' for normal code
|
// This should only be used for testing - use 'find' for normal code
|
||||||
// to avoid Mongo-format dependencies.
|
// to avoid Mongo-format dependencies.
|
||||||
// Returns a promise that resolves to a list of items.
|
// Returns a promise that resolves to a list of items.
|
||||||
ExportAdapter.prototype.mongoFind = function(className, query, options) {
|
ExportAdapter.prototype.mongoFind = function(className, query, options = {}) {
|
||||||
options = options || {};
|
|
||||||
return this.collection(className).then((coll) => {
|
return this.collection(className).then((coll) => {
|
||||||
return coll.find(query, options).toArray();
|
return coll.find(query, options).toArray();
|
||||||
});
|
});
|
||||||
@@ -503,8 +499,7 @@ ExportAdapter.prototype.smartFind = function(coll, where, options) {
|
|||||||
// TODO: make userIds not needed here. The db adapter shouldn't know
|
// TODO: make userIds not needed here. The db adapter shouldn't know
|
||||||
// anything about users, ideally. Then, improve the format of the ACL
|
// anything about users, ideally. Then, improve the format of the ACL
|
||||||
// arg to work like the others.
|
// arg to work like the others.
|
||||||
ExportAdapter.prototype.find = function(className, query, options) {
|
ExportAdapter.prototype.find = function(className, query, options = {}) {
|
||||||
options = options || {};
|
|
||||||
var mongoOptions = {};
|
var mongoOptions = {};
|
||||||
if (options.skip) {
|
if (options.skip) {
|
||||||
mongoOptions.skip = options.skip;
|
mongoOptions.skip = options.skip;
|
||||||
|
|||||||
@@ -11,13 +11,12 @@ var Parse = require('parse/node').Parse;
|
|||||||
// include
|
// include
|
||||||
// keys
|
// keys
|
||||||
// redirectClassNameForKey
|
// redirectClassNameForKey
|
||||||
function RestQuery(config, auth, className, restWhere, restOptions) {
|
function RestQuery(config, auth, className, restWhere = {}, restOptions = {}) {
|
||||||
restOptions = restOptions || {};
|
|
||||||
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.auth = auth;
|
this.auth = auth;
|
||||||
this.className = className;
|
this.className = className;
|
||||||
this.restWhere = restWhere || {};
|
this.restWhere = restWhere;
|
||||||
this.response = null;
|
this.response = null;
|
||||||
|
|
||||||
this.findOptions = {};
|
this.findOptions = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user