Skip to content

Commit

Permalink
Merge pull request #3: Replace binary columns with text
Browse files Browse the repository at this point in the history
Replace binary columns with text
  • Loading branch information
marcelklehr authored Sep 22, 2016
2 parents c08474a + 1f3395a commit 065c463
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions components/models/src/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = function(ot) {
//, id (auto-incrementing)
//, createdAt
//, updatedAt

}

// Class methods
Expand All @@ -65,22 +65,22 @@ module.exports = function(ot) {
function* createWithSnapshot(obj) {
var ottype = ot.getOTType(obj.type)
if(!ottype) throw new Error('Specified document type is not available')

var edit = gulf.Edit.newInitial(ottype)
var contents = ottype.serialize? ottype.serialize(ottype.create()) : ottype.create()
obj.firstSnapshot = edit.id
obj.latestSnapshot = edit
var doc = yield this.create(obj)

var snapshot = {
id: edit.id
, document: doc.id
, changes: JSON.stringify(edit.changeset)
, contents: new Buffer(JSON.stringify(contents))
, contents: JSON.stringify(contents)
//, author: not given, since this not a change, but an initial snapshot
}
// `create` throws in MySql for example, because the doc creation triggers the creation of an empty snapshot with that id :/
yield this.waterline.collections.snapshot.update({id: edit.id}, snapshot)
yield this.waterline.collections.snapshot.update({id: edit.id}, snapshot)
return doc
}

Expand Down
8 changes: 4 additions & 4 deletions components/models/src/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU General Public License for more details.te
*
* You should have received a copy of the Mozilla Public License
* along with this program. If not, see <https://www.mozilla.org/en-US/MPL/2.0/>.
Expand All @@ -29,10 +29,10 @@ module.exports = {
}

// the changeset
, changes: 'binary'
, changes: 'mediumtext'

// the content resulting from the changes
, contents: 'binary'
, contents: 'mediumtext'

// belongsTo a document
, document: {
Expand All @@ -43,7 +43,7 @@ module.exports = {
, author: {
model: 'user'
}

, parent: {
model: 'snapshot'
}
Expand Down
2 changes: 1 addition & 1 deletion components/sync/lib/waterline-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Adapter.prototype.storeSnapshot = function(docId, snapshot, cb) {
this.Snapshot.create({
changes: snapshot.changes
, parent: snapshot.parent
, contents: new Buffer(JSON.stringify(snapshot.contents))
, contents: JSON.stringify(snapshot.contents)
, id: snapshot.id
, document: docId
, author: snapshot.author
Expand Down

0 comments on commit 065c463

Please sign in to comment.