Remove schemaController parameter
This commit is contained in:
@@ -121,7 +121,7 @@ describe('transformWhere', () => {
|
|||||||
describe('mongoObjectToParseObject', () => {
|
describe('mongoObjectToParseObject', () => {
|
||||||
it('built-in timestamps', (done) => {
|
it('built-in timestamps', (done) => {
|
||||||
var input = {createdAt: new Date(), updatedAt: new Date()};
|
var input = {createdAt: new Date(), updatedAt: new Date()};
|
||||||
var output = transform.mongoObjectToParseObject(dummySchema, null, input, { fields: {} });
|
var output = transform.mongoObjectToParseObject(null, input, { fields: {} });
|
||||||
expect(typeof output.createdAt).toEqual('string');
|
expect(typeof output.createdAt).toEqual('string');
|
||||||
expect(typeof output.updatedAt).toEqual('string');
|
expect(typeof output.updatedAt).toEqual('string');
|
||||||
done();
|
done();
|
||||||
@@ -129,7 +129,7 @@ describe('mongoObjectToParseObject', () => {
|
|||||||
|
|
||||||
it('pointer', (done) => {
|
it('pointer', (done) => {
|
||||||
var input = {_p_userPointer: '_User$123'};
|
var input = {_p_userPointer: '_User$123'};
|
||||||
var output = transform.mongoObjectToParseObject(dummySchema, null, input, {
|
var output = transform.mongoObjectToParseObject(null, input, {
|
||||||
fields: { userPointer: { type: 'Pointer', targetClass: '_User' } },
|
fields: { userPointer: { type: 'Pointer', targetClass: '_User' } },
|
||||||
});
|
});
|
||||||
expect(typeof output.userPointer).toEqual('object');
|
expect(typeof output.userPointer).toEqual('object');
|
||||||
@@ -141,7 +141,7 @@ describe('mongoObjectToParseObject', () => {
|
|||||||
|
|
||||||
it('null pointer', (done) => {
|
it('null pointer', (done) => {
|
||||||
var input = {_p_userPointer: null};
|
var input = {_p_userPointer: null};
|
||||||
var output = transform.mongoObjectToParseObject(dummySchema, null, input, {
|
var output = transform.mongoObjectToParseObject(null, input, {
|
||||||
fields: { userPointer: { type: 'Pointer', targetClass: '_User' } },
|
fields: { userPointer: { type: 'Pointer', targetClass: '_User' } },
|
||||||
});
|
});
|
||||||
expect(output.userPointer).toBeUndefined();
|
expect(output.userPointer).toBeUndefined();
|
||||||
@@ -150,7 +150,7 @@ describe('mongoObjectToParseObject', () => {
|
|||||||
|
|
||||||
it('file', (done) => {
|
it('file', (done) => {
|
||||||
var input = {picture: 'pic.jpg'};
|
var input = {picture: 'pic.jpg'};
|
||||||
var output = transform.mongoObjectToParseObject(dummySchema, null, input, {
|
var output = transform.mongoObjectToParseObject(null, input, {
|
||||||
fields: { picture: { type: 'File' }},
|
fields: { picture: { type: 'File' }},
|
||||||
});
|
});
|
||||||
expect(typeof output.picture).toEqual('object');
|
expect(typeof output.picture).toEqual('object');
|
||||||
@@ -160,7 +160,7 @@ describe('mongoObjectToParseObject', () => {
|
|||||||
|
|
||||||
it('geopoint', (done) => {
|
it('geopoint', (done) => {
|
||||||
var input = {location: [180, -180]};
|
var input = {location: [180, -180]};
|
||||||
var output = transform.mongoObjectToParseObject(dummySchema, null, input, {
|
var output = transform.mongoObjectToParseObject(null, input, {
|
||||||
fields: { location: { type: 'GeoPoint' }},
|
fields: { location: { type: 'GeoPoint' }},
|
||||||
});
|
});
|
||||||
expect(typeof output.location).toEqual('object');
|
expect(typeof output.location).toEqual('object');
|
||||||
@@ -172,7 +172,7 @@ describe('mongoObjectToParseObject', () => {
|
|||||||
|
|
||||||
it('nested array', (done) => {
|
it('nested array', (done) => {
|
||||||
var input = {arr: [{_testKey: 'testValue' }]};
|
var input = {arr: [{_testKey: 'testValue' }]};
|
||||||
var output = transform.mongoObjectToParseObject(dummySchema, null, input, {
|
var output = transform.mongoObjectToParseObject(null, input, {
|
||||||
fields: { arr: { type: 'Array' } },
|
fields: { arr: { type: 'Array' } },
|
||||||
});
|
});
|
||||||
expect(Array.isArray(output.arr)).toEqual(true);
|
expect(Array.isArray(output.arr)).toEqual(true);
|
||||||
@@ -192,7 +192,7 @@ describe('mongoObjectToParseObject', () => {
|
|||||||
},
|
},
|
||||||
regularKey: "some data",
|
regularKey: "some data",
|
||||||
}]}
|
}]}
|
||||||
let output = transform.mongoObjectToParseObject(dummySchema, null, input, {
|
let output = transform.mongoObjectToParseObject(null, input, {
|
||||||
fields: { array: { type: 'Array' }},
|
fields: { array: { type: 'Array' }},
|
||||||
});
|
});
|
||||||
expect(dd(output, input)).toEqual(undefined);
|
expect(dd(output, input)).toEqual(undefined);
|
||||||
@@ -262,7 +262,7 @@ describe('transform schema key changes', () => {
|
|||||||
_rperm: ["*"],
|
_rperm: ["*"],
|
||||||
_wperm: ["Kevin"]
|
_wperm: ["Kevin"]
|
||||||
};
|
};
|
||||||
var output = transform.mongoObjectToParseObject(dummySchema, null, input, { fields: {} });
|
var output = transform.mongoObjectToParseObject(null, input, { fields: {} });
|
||||||
expect(typeof output.ACL).toEqual('object');
|
expect(typeof output.ACL).toEqual('object');
|
||||||
expect(output._rperm).toBeUndefined();
|
expect(output._rperm).toBeUndefined();
|
||||||
expect(output._wperm).toBeUndefined();
|
expect(output._wperm).toBeUndefined();
|
||||||
@@ -276,7 +276,7 @@ describe('transform schema key changes', () => {
|
|||||||
long: mongodb.Long.fromNumber(Number.MAX_SAFE_INTEGER),
|
long: mongodb.Long.fromNumber(Number.MAX_SAFE_INTEGER),
|
||||||
double: new mongodb.Double(Number.MAX_VALUE)
|
double: new mongodb.Double(Number.MAX_VALUE)
|
||||||
}
|
}
|
||||||
var output = transform.mongoObjectToParseObject(dummySchema, null, input, {
|
var output = transform.mongoObjectToParseObject(null, input, {
|
||||||
fields: {
|
fields: {
|
||||||
long: { type: 'Number' },
|
long: { type: 'Number' },
|
||||||
double: { type: 'Number' },
|
double: { type: 'Number' },
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ export class MongoStorageAdapter {
|
|||||||
find(className, query, { skip, limit, sort }, schemaController, schema) {
|
find(className, query, { skip, limit, sort }, schemaController, schema) {
|
||||||
return this.adaptiveCollection(className)
|
return this.adaptiveCollection(className)
|
||||||
.then(collection => collection.find(query, { skip, limit, sort }))
|
.then(collection => collection.find(query, { skip, limit, sort }))
|
||||||
.then(objects => objects.map(object => transform.mongoObjectToParseObject(schemaController, className, object, schema)));
|
.then(objects => objects.map(object => transform.mongoObjectToParseObject(className, object, schema)));
|
||||||
}
|
}
|
||||||
|
|
||||||
get transform() {
|
get transform() {
|
||||||
|
|||||||
@@ -755,7 +755,7 @@ const nestedMongoObjectToNestedParseObject = mongoObject => {
|
|||||||
|
|
||||||
// Converts from a mongo-format object to a REST-format object.
|
// Converts from a mongo-format object to a REST-format object.
|
||||||
// Does not strip out anything based on a lack of authentication.
|
// Does not strip out anything based on a lack of authentication.
|
||||||
const mongoObjectToParseObject = (schemaController, className, mongoObject, schema) => {
|
const mongoObjectToParseObject = (className, mongoObject, schema) => {
|
||||||
switch(typeof mongoObject) {
|
switch(typeof mongoObject) {
|
||||||
case 'string':
|
case 'string':
|
||||||
case 'number':
|
case 'number':
|
||||||
|
|||||||
Reference in New Issue
Block a user