Beispiel #1
0
				db.users.update({_id: everUserId}, {$set: data}, function(err, cnt) {

					if(err || cnt == 0) {
						console.log('用户信息更新失败', err);

					} else {
						Evt.setHost(me.host);
						console.log('用户信息更新成功');

						db.notes.update({UserId: everUserId}, {$set: {UserId: me.userId, IsDirty: true, ServerNoteId: '', LocalIsNew: true}}, {multi: true}, function () {
							console.log('notes 数据更新成功');
						});

						db.notebooks.update({UserId: everUserId}, {$set: {UserId: me.userId, IsDirty: true, ServerNotebookId: '', LocalIsNew: true}}, {multi: true}, function () {
							console.log('notebooks 数据更新成功');
						});
						db.tags.update({UserId: everUserId}, {$set: {UserId: me.userId, IsDirty: true}}, {multi: true}, function () {
							console.log('tags 数据更新成功');
						});

						db.attachs.update({UserId: everUserId}, {$set: {UserId: me.userId, ServerFileId: '', IsDirty: true}}, {multi: true}, function () {
							console.log('attachs 数据更新成功');
						});

						dbClient.images.update({UserId: everUserId}, {$set: {UserId: me.userId, ServerFileId: '', IsDirty: true}}, {multi: true}, function () {
							console.log('images 数据更新成功');
						});
					}
				});
Beispiel #2
0
			}, function(err, count) {
			if(err) {
				log(err);
				return;
			}
			Web.updateNotebookNumberNotes(notebookId, count);
			db.notebooks.update({NotebookId: notebookId}, {$set: {NumberNotes: count}}, {})
		});
Beispiel #3
0
	updateNotebookTitle: function(notebookId, title, callback) {
		db.notebooks.update({NotebookId: notebookId}, 
			{$set: 
				{Title: title, IsDirty: true, UpdatedTime: new Date()}
			}, function(err, n) {
			callback(true);
		});
	},
Beispiel #4
0
		Note.hasNotes(notebookId, function(has) {
			if(has) {
				callback(false, 'This notebook has notes, please delete notes firstly.');
			} else {
				db.notebooks.update({NotebookId: notebookId}, {$set: {LocalIsDelete: true, IsDirty: true, UpdatedTime: new Date()}}, function(err, n) {
					callback(true);
				});
			}
		});
Beispiel #5
0
		me.getNotebookIdByServerNotebookId(notebook.ParentNotebookId, function(parentNotebookId) {
			notebook.ParentNotebookId = parentNotebookId;
			notebook.ServerNotebookId = notebook.NotebookId;
			notebook.NotebookId = notebookLocal.NotebookId;
			db.notebooks.update({ServerNotebookId: serverNotebookId}, {$set: notebook}, {}, function (err, updates) {   // Callback is optional
				if(err) {
					console.log(err);
					callback && callback(false);
				} else {
					callback && callback(notebook);
				}
			});
		});
Beispiel #6
0
		me.getNotebookIdByServerNotebookId(notebook.ParentNotebookId, function(parentNotebookId) {
			notebook.ParentNotebookId = parentNotebookId;
			// console.log(notebook2);
			// notebook2.Title  += " H-";
			// multi, 因为历史原因, 导致大量重复notebookId的元素
			db.notebooks.update({NotebookId: notebookId}, {$set: notebook}, {multi: true}, function (err, n) {
				// console.log('updateNotebookForceForSendChange end' + notebookId + ' ' + n);
				if(err) {
					console.log(err);
					callback && callback(false);
				} else {
					callback && callback(notebook);
				}
			});
		});
Beispiel #7
0
		me.getNotebook(curNotebookId, function(notebook) {
			if(!notebook) {
				console.log('not fount');
				return;
			}
			// 先更新之
			// db.notebooks.update({NotebookId: notebookId}, {$set: {ParentNotebookId: parentNotebookId, IsDirty: true, UpdatedTime: new Date()}}, function(err, n) {
			// });
			siblingNotebookIds = siblingNotebookIds || [];
			// 再更新所有子孩子的seq
			for(var i = 0; i < siblingNotebookIds.length; ++i) {
				var siblingNotebookId = siblingNotebookIds[i];
				console.log('siblingNotebookId: ' + siblingNotebookId);
				db.notebooks.update({NotebookId: siblingNotebookId}, 
					{$set: 
						{ParentNotebookId: parentNotebookId, Seq: i, IsDirty: true, UpdatedTime: new Date()}
					}
				);
			}
		});
Beispiel #8
0
	setIsNew: function(notebookId) {
		db.notebooks.update({NotebookId: notebookId}, {$set:{LocalIsNew: true, IsDirty: true}})
	}
Beispiel #9
0
	setNotDirtyNotDelete: function(notebookId) {
		db.notebooks.update({NotebookId: notebookId}, {$set:{IsDirty: false, LocalIsDelete: false}})
	},