Skip to content

Incorporate vitaly-t changes #2085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions src/Adapters/Storage/Postgres/PostgresStorageAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ export class PostgresStorageAdapter {
};

classExists(name) {
return Promise.reject('Not implented yet.')
return Promise.reject('Not implemented yet.')
}

setClassLevelPermissions(className, CLPs) {
return Promise.reject('Not implented yet.')
return Promise.reject('Not implemented yet.')
}

createClass(className, schema) {
Expand Down Expand Up @@ -136,7 +136,7 @@ export class PostgresStorageAdapter {
}

addFieldIfNotExists(className, fieldName, type) {
// TODO: Doing this in a transaction might be a good idea.
// TODO: Must be re-done into a transaction!
return this._client.query('ALTER TABLE $<className:name> ADD COLUMN $<fieldName:name> $<postgresType:raw>', { className, fieldName, postgresType: parseTypeToPostgresType(type) })
.catch(error => {
if (error.code === PostgresRelationDoesNotExistError) {
Expand Down Expand Up @@ -165,10 +165,10 @@ export class PostgresStorageAdapter {
// Drops a collection. Resolves with true if it was a Parse Schema (eg. _User, Custom, etc.)
// and resolves with false if it wasn't (eg. a join table). Rejects if deletion was impossible.
deleteClass(className) {
return Promise.reject('Not implented yet.')
return Promise.reject('Not implemented yet.')
}

// Delete all data known to this adatper. Used for testing.
// Delete all data known to this adapter. Used for testing.
deleteAllClasses() {
return this._client.query('SELECT "className" FROM "_SCHEMA"')
.then(results => {
Expand All @@ -192,29 +192,21 @@ export class PostgresStorageAdapter {
// deleted do not exist, this function should return successfully anyways. Checking for
// attempts to delete non-existent fields is the responsibility of Parse Server.

// Pointer field names are passed for legacy reasons: the original mongo
// format stored pointer field names differently in the database, and therefore
// needed to know the type of the field before it could delete it. Future database
// adatpers should ignore the pointerFieldNames argument. All the field names are in
// fieldNames, they show up additionally in the pointerFieldNames database for use
// by the mongo adapter, which deals with the legacy mongo format.

// This function is not obligated to delete fields atomically. It is given the field
// names in a list so that databases that are capable of deleting fields atomically
// may do so.

// Returns a Promise.
deleteFields(className, schema, fieldNames) {
return Promise.reject('Not implented yet.')
return Promise.reject('Not implemented yet.')
}

// Return a promise for all schemas known to this adapter, in Parse format. In case the
// schemas cannot be retrieved, returns a promise that rejects. Rquirements for the
// schemas cannot be retrieved, returns a promise that rejects. Requirements for the
// rejection reason are TBD.
getAllClasses() {
return this._ensureSchemaCollectionExists()
.then(() => this._client.query('SELECT * FROM "_SCHEMA"'))
.then(results => results.map(result => ({ className: result.className, ...result.schema })))
.then(() => this._client.map('SELECT * FROM "_SCHEMA"'), null, row => ({ className: row.className, ...row.schema }));
}

// Return a promise for the schema with the given name, in Parse format. If
Expand Down Expand Up @@ -280,7 +272,7 @@ export class PostgresStorageAdapter {

// Apply the update to all objects that match the given Parse Query.
updateObjectsByQuery(className, schema, query, update) {
return Promise.reject('Not implented yet.')
return Promise.reject('Not implemented yet.')
}

// Return value not currently well specified.
Expand Down Expand Up @@ -310,14 +302,12 @@ export class PostgresStorageAdapter {

let qs = `UPDATE $1:name SET ${updatePatterns.join(',')} WHERE ${where.pattern} RETURNING *`;
return this._client.query(qs, values)
.then(val => {
return val[0];
})
.then(val => val[0]); // TODO: This is unsafe, verification is needed, or a different query method;
}

// Hopefully we can get rid of this. It's only used for config and hooks.
// Hopefully, we can get rid of this. It's only used for config and hooks.
upsertOneObject(className, schema, query, update) {
return Promise.reject('Not implented yet.')
return Promise.reject('Not implemented yet.')
}

find(className, schema, query, { skip, limit, sort }) {
Expand Down Expand Up @@ -369,9 +359,9 @@ export class PostgresStorageAdapter {
return this._client.query(qs,[className, constraintName, ...fieldNames])
}

// Executs a count.
// Executes a count.
count(className, schema, query) {
return Promise.reject('Not implented yet.')
return Promise.reject('Not implemented yet.')
}
}

Expand Down