@@ -30,20 +30,11 @@ export class PostgresStorageAdapter {
30
30
} ;
31
31
32
32
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.' )
39
34
}
40
35
41
36
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.' )
47
38
}
48
39
49
40
createClass ( className , schema ) {
@@ -78,19 +69,7 @@ export class PostgresStorageAdapter {
78
69
// Drops a collection. Resolves with true if it was a Parse Schema (eg. _User, Custom, etc.)
79
70
// and resolves with false if it wasn't (eg. a join table). Rejects if deletion was impossible.
80
71
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.' )
94
73
}
95
74
96
75
// Delete all data known to this adatper. Used for testing.
@@ -130,28 +109,7 @@ export class PostgresStorageAdapter {
130
109
131
110
// Returns a Promise.
132
111
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.' )
155
113
}
156
114
157
115
// Return a promise for all schemas known to this adapter, in Parse format. In case the
@@ -187,47 +145,22 @@ export class PostgresStorageAdapter {
187
145
// If no objects match, reject with OBJECT_NOT_FOUND. If objects are found and deleted, resolve with undefined.
188
146
// If there is some other error, reject with INTERNAL_SERVER_ERROR.
189
147
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.' )
204
149
}
205
150
206
151
// Apply the update to all objects that match the given Parse Query.
207
152
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.' )
213
154
}
214
155
215
156
// Hopefully we can get rid of this in favor of updateObjectsByQuery.
216
157
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.' )
222
159
}
223
160
224
161
// Hopefully we can get rid of this. It's only used for config and hooks.
225
162
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.' )
231
164
}
232
165
233
166
// Executes a find. Accepts: className, query in Parse format, and { skip, limit, sort }.
@@ -241,29 +174,12 @@ export class PostgresStorageAdapter {
241
174
// Way of determining if a field is nullable. Undefined doesn't count against uniqueness,
242
175
// which is why we use sparse indexes.
243
176
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.' )
260
178
}
261
179
262
180
// Executs a count.
263
181
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.' )
267
183
}
268
184
}
269
185
0 commit comments