angular.module('pie')
.factory('documentService', function($http, apiBaseUrl) {
	return {
		currentDocument: undefined,
		get: function(id) {
			var t = this;
			var p = $http({
				method: "GET",
				url: apiBaseUrl + "/documents/" + id,
				withCredentials: true
			});
			p.success(function(data) {
				t.currentDocument = data;
			});
			return p;
		},
		post: function() {
			var p = $http({
				method: "POST",
				url: apiBaseUrl + "/documents",
				data : this.currentDocument,
				withCredentials: true
			});
			return p;
		},
		update: function() {
			var p = $http({
				method: "PUT",
				url: apiBaseUrl + "/documents/" + this.currentDocument._id,
				data : this.currentDocument,
				withCredentials: true
			});
			return p;
		},
		create: function() {
			this.currentDocument = {
				title: '',
				owner : '',
				content: [
					{ title: '', level: 1},
					{ title: '', level: 1},
					{ title: '', level: 1}
				]
			};
		}
	};
});
@@ -838,25 +838,24 @@
 nt: %5B%0A%09%09%09%09%09%7B
- 
 title: '', l
@@ -853,32 +853,49 @@
 le: '', level: 1
+, discussions: %5B%5D
 %7D,%0A%09%09%09%09%09%7B title:
@@ -879,33 +879,32 @@
 ons: %5B%5D%7D,%0A%09%09%09%09%09%7B
- 
 title: '', level
@@ -906,16 +906,33 @@
 level: 1
+, discussions: %5B%5D
 %7D,%0A%09%09%09%09%09
@@ -932,17 +932,16 @@
 ,%0A%09%09%09%09%09%7B
- 
 title: '
@@ -955,20 +955,292 @@
 l: 1
-%7D%0A%09%09%09%09%5D%0A%09%09%09%7D
+, discussions: %5B%5D%7D%0A%09%09%09%09%5D,%0A%09%09%09%09docId: undefined,%0A%09%09%09%09version: undefined%0A%09%09%09%7D;%0A%09%09%7D,%0A%09%09newVersion: function() %7B%0A%09%09%09this.currentDocument.version = undefined;%0A%09%09%09this.currentDocument._id = undefined;%0A%09%09%09_.each(this.currentDocument.content, function(elem) %7B%0A%09%09%09%09elem.discussions = %5B%5D;%0A%09%09%09%7D)
 ;%0A%09%09
@@ -1248,8 +1248,9 @@
 %0A%09%7D;%0A%7D);
+%0A

Update documentService.js