Skip to content

Commit 2e9127b

Browse files
committed
Remove mongo implementations and fix test
1 parent 19b3720 commit 2e9127b

File tree

2 files changed

+12
-99
lines changed

2 files changed

+12
-99
lines changed

spec/ParseAPI.spec.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var TestUtils = require('../src/index').TestUtils;
1313
const requiredUserFields = { fields: Object.assign({}, defaultColumns._Default, defaultColumns._User) };
1414

1515
describe('miscellaneous', function() {
16-
fit('create a GameScore object', function(done) {
16+
it('create a GameScore object', function(done) {
1717
var obj = new Parse.Object('GameScore');
1818
obj.set('score', 1337);
1919
obj.save().then(function(obj) {
@@ -121,10 +121,7 @@ describe('miscellaneous', function() {
121121
fail('one of the users should not have been created');
122122
done();
123123
})
124-
.catch(error => {
125-
fail('index build failed')
126-
done();
127-
});
124+
.catch(done);
128125
});
129126

130127
it('ensure that if people already have duplicate users, they can still sign up new users', done => {

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

Lines changed: 10 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,11 @@ export class PostgresStorageAdapter {
3030
};
3131

3232
classExists(name) {
33-
console.log('classExists(name) {')
34-
return this.connect().then(() => {
35-
return this.database.listCollections({ name: this._collectionPrefix + name }).toArray();
36-
}).then(collections => {
37-
return collections.length > 0;
38-
});
33+
return Promise.reject('Not implented yet.')
3934
}
4035

4136
setClassLevelPermissions(className, CLPs) {
42-
console.log('setClassLevelPermissions(className, CLPs) {')
43-
return this._schemaCollection()
44-
.then(schemaCollection => schemaCollection.updateSchema(className, {
45-
$set: { _metadata: { class_permissions: CLPs } }
46-
}));
37+
return Promise.reject('Not implented yet.')
4738
}
4839

4940
createClass(className, schema) {
@@ -78,19 +69,7 @@ export class PostgresStorageAdapter {
7869
// Drops a collection. Resolves with true if it was a Parse Schema (eg. _User, Custom, etc.)
7970
// and resolves with false if it wasn't (eg. a join table). Rejects if deletion was impossible.
8071
deleteClass(className) {
81-
console.log('deleteClass(className) {')
82-
return this._adaptiveCollection(className)
83-
.then(collection => collection.drop())
84-
.catch(error => {
85-
// 'ns not found' means collection was already gone. Ignore deletion attempt.
86-
if (error.message == 'ns not found') {
87-
return;
88-
}
89-
throw error;
90-
})
91-
// We've dropped the collection, now remove the _SCHEMA document
92-
.then(() => this._schemaCollection())
93-
.then(schemaCollection => schemaCollection.findAndDeleteSchema(className))
72+
return Promise.reject('Not implented yet.')
9473
}
9574

9675
// Delete all data known to this adatper. Used for testing.
@@ -130,28 +109,7 @@ export class PostgresStorageAdapter {
130109

131110
// Returns a Promise.
132111
deleteFields(className, schema, fieldNames) {
133-
console.log('deleteFields(className, schema, fieldNames) {')
134-
const mongoFormatNames = fieldNames.map(fieldName => {
135-
if (schema.fields[fieldName].type === 'Pointer') {
136-
return `_p_${fieldName}`
137-
} else {
138-
return fieldName;
139-
}
140-
});
141-
const collectionUpdate = { '$unset' : {} };
142-
mongoFormatNames.forEach(name => {
143-
collectionUpdate['$unset'][name] = null;
144-
});
145-
146-
const schemaUpdate = { '$unset' : {} };
147-
fieldNames.forEach(name => {
148-
schemaUpdate['$unset'][name] = null;
149-
});
150-
151-
return this._adaptiveCollection(className)
152-
.then(collection => collection.updateMany({}, collectionUpdate))
153-
.then(() => this._schemaCollection())
154-
.then(schemaCollection => schemaCollection.updateSchema(className, schemaUpdate));
112+
return Promise.reject('Not implented yet.')
155113
}
156114

157115
// Return a promise for all schemas known to this adapter, in Parse format. In case the
@@ -187,47 +145,22 @@ export class PostgresStorageAdapter {
187145
// If no objects match, reject with OBJECT_NOT_FOUND. If objects are found and deleted, resolve with undefined.
188146
// If there is some other error, reject with INTERNAL_SERVER_ERROR.
189147
deleteObjectsByQuery(className, schema, query) {
190-
console.log('deleteObjectsByQuery(className, schema, query) {')
191-
return this._adaptiveCollection(className)
192-
.then(collection => {
193-
let mongoWhere = transformWhere(className, query, schema);
194-
return collection.deleteMany(mongoWhere)
195-
})
196-
.then(({ result }) => {
197-
if (result.n === 0) {
198-
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Object not found.');
199-
}
200-
return Promise.resolve();
201-
}, error => {
202-
throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'Database adapter error');
203-
});
148+
return Promise.reject('Not implented yet.')
204149
}
205150

206151
// Apply the update to all objects that match the given Parse Query.
207152
updateObjectsByQuery(className, schema, query, update) {
208-
console.log('updateObjectsByQuery(className, schema, query, update) {')
209-
const mongoUpdate = transformUpdate(className, update, schema);
210-
const mongoWhere = transformWhere(className, query, schema);
211-
return this._adaptiveCollection(className)
212-
.then(collection => collection.updateMany(mongoWhere, mongoUpdate));
153+
return Promise.reject('Not implented yet.')
213154
}
214155

215156
// Hopefully we can get rid of this in favor of updateObjectsByQuery.
216157
findOneAndUpdate(className, schema, query, update) {
217-
console.log('findOneAndUpdate(className, schema, query, update) {')
218-
const mongoUpdate = transformUpdate(className, update, schema);
219-
const mongoWhere = transformWhere(className, query, schema);
220-
return this._adaptiveCollection(className)
221-
.then(collection => collection.findOneAndUpdate(mongoWhere, mongoUpdate));
158+
return Promise.reject('Not implented yet.')
222159
}
223160

224161
// Hopefully we can get rid of this. It's only used for config and hooks.
225162
upsertOneObject(className, schema, query, update) {
226-
console.log('upsertOneObject(className, schema, query, update) {')
227-
const mongoUpdate = transformUpdate(className, update, schema);
228-
const mongoWhere = transformWhere(className, query, schema);
229-
return this._adaptiveCollection(className)
230-
.then(collection => collection.upsertOne(mongoWhere, mongoUpdate));
163+
return Promise.reject('Not implented yet.')
231164
}
232165

233166
// Executes a find. Accepts: className, query in Parse format, and { skip, limit, sort }.
@@ -241,29 +174,12 @@ export class PostgresStorageAdapter {
241174
// Way of determining if a field is nullable. Undefined doesn't count against uniqueness,
242175
// which is why we use sparse indexes.
243176
ensureUniqueness(className, schema, fieldNames) {
244-
console.log('ensureUniqueness(className, schema, fieldNames) {')
245-
return Promise.resolve();
246-
let indexCreationRequest = {};
247-
let mongoFieldNames = fieldNames.map(fieldName => transformKey(className, fieldName, schema));
248-
mongoFieldNames.forEach(fieldName => {
249-
indexCreationRequest[fieldName] = 1;
250-
});
251-
return this._adaptiveCollection(className)
252-
.then(collection => collection._ensureSparseUniqueIndexInBackground(indexCreationRequest))
253-
.catch(error => {
254-
if (error.code === 11000) {
255-
throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'Tried to ensure field uniqueness for a class that already has duplicates.');
256-
} else {
257-
throw error;
258-
}
259-
});
177+
return Promise.resolve('ensureUniqueness not implented yet.')
260178
}
261179

262180
// Executs a count.
263181
count(className, schema, query) {
264-
console.log('count(className, schema, query) {')
265-
return this._adaptiveCollection(className)
266-
.then(collection => collection.count(transformWhere(className, query, schema)));
182+
return Promise.reject('Not implented yet.')
267183
}
268184
}
269185

0 commit comments

Comments
 (0)