This commit is contained in:
Drew Gross
2016-06-13 00:57:23 -07:00
parent 634d672ad1
commit 452b737be4
7 changed files with 65 additions and 99 deletions

View File

@@ -52,7 +52,7 @@ export default class MongoCollection {
// If there is nothing that matches the query - does insert
// Postgres Note: `INSERT ... ON CONFLICT UPDATE` that is available since 9.5.
upsertOne(query, update) {
return this._mongoCollection.update(query, update, { upsert: true });
return this._mongoCollection.update(query, update, { upsert: true })
}
updateOne(query, update) {

View File

@@ -281,10 +281,14 @@ const parseObjectToMongoObjectForCreate = (className, restCreate, schema) => {
}
// Use the legacy mongo format for createdAt and updatedAt
mongoCreate._created_at = mongoCreate.createdAt.iso;
delete mongoCreate.createdAt;
mongoCreate._updated_at = mongoCreate.updatedAt.iso;
delete mongoCreate.updatedAt;
if (mongoCreate.createdAt) {
mongoCreate._created_at = new Date(mongoCreate.createdAt.iso || mongoCreate.createdAt);
delete mongoCreate.createdAt;
}
if (mongoCreate.updatedAt) {
mongoCreate._updated_at = new Date(mongoCreate.updatedAt.iso || mongoCreate.updatedAt);
delete mongoCreate.updatedAt;
}
return mongoCreate;
}

View File

@@ -166,6 +166,11 @@ export class PostgresStorageAdapter {
createObject(className, schema, object) {
let columnsArray = [];
let valuesArray = [];
console.log('creating');
console.log(schema);
console.log(object);
console.log(className);
console.log(new Error().stack);
Object.keys(object).forEach(fieldName => {
columnsArray.push(fieldName);
switch (schema.fields[fieldName].type) {