@@ -50,6 +50,9 @@ ArticleProvider.prototype.save = function(articles, callback) {
50
50
articles = [ articles ] ;
51
51
for ( var i = 0 ; i < articles . length ; i ++ ) {
52
52
article = articles [ i ] ;
53
+ text_to_replace = articles [ i ] . body ;
54
+ var paragraphs = article . body . split ( '\r\n\r\n' ) ;
55
+ article . body = paragraphs ;
53
56
article . created_at = new Date ( ) ;
54
57
if ( article . comments === undefined ) article . comments = [ ] ;
55
58
for ( var j = 0 ; j < article . comments . length ; j ++ ) {
@@ -64,6 +67,20 @@ ArticleProvider.prototype.save = function(articles, callback) {
64
67
} ) ;
65
68
} ;
66
69
70
+ ArticleProvider . prototype . delete = function ( articleId , callback ) {
71
+ this . getCollection ( function ( error , article_collection ) {
72
+ if ( error ) callback ( error ) ;
73
+ else {
74
+ article_collection . remove (
75
+ { _id : article_collection . db . bson_serializer . ObjectID . createFromHexString ( articleId ) } ,
76
+ function ( error , article ) {
77
+ if ( error ) callback ( error ) ;
78
+ else callback ( null , article )
79
+ } ) ;
80
+ }
81
+ } ) ;
82
+ } ;
83
+
67
84
ArticleProvider . prototype . addCommentToArticle = function ( articleId , comment , callback ) {
68
85
this . getCollection ( function ( error , article_collection ) {
69
86
if ( error ) callback ( error ) ;
0 commit comments