send tag changes ok

This commit is contained in:
life
2015-02-07 01:29:33 +08:00
parent 8b329de3bb
commit 6b574aa208
3 changed files with 36 additions and 23 deletions

18
node_modules/tag.js generated vendored
View File

@@ -1,7 +1,7 @@
var db = require('db');
var Common = require('common');
var User = require('user');
var Note = require('note');
// var Note = require('note');
var Web = require('web');
var Tags = db.tags;
/*
@@ -19,11 +19,12 @@ Count 笔记数
var Tag = {
// 添加或更新标签
addOrUpdateTag: function(title, callback, isForce) {
addOrUpdateTag: function(title, callback, isForce, usn) {
var userId = User.getCurActiveUserId();
Tags.findOne({UserId: userId, Tag: title}, function(err, tag) {
// 存在, 则更新该tag下的笔记数量
// 已存的, 不更新IsDirty
var Note = require('note');
if(!err && tag) {
Note.countNoteByTag(title, function(cnt) {
tag.Count = cnt;
@@ -39,6 +40,7 @@ var Tag = {
UserId: userId,
Tag: title,
IsDirty: !isForce, // 新添加的
Usn: usn, // 在isForce == true时用, 服务器添加过来的
Count: 1,
LocalIsDelete: false,
CreatedTime: date,
@@ -69,6 +71,8 @@ var Tag = {
Tags.update({UserId: User.getCurActiveUserId(), Tag: title}, {$set: {LocalIsDelete: true, IsDirty: !isForce, UpdatedTime: new Date()}}, function() {
});
//
var Note = require('./note');
console.log(Note);
Note.updateNoteToDeleteTag(title, function(updates) {
callback && callback(updates);
});
@@ -97,7 +101,15 @@ var Tag = {
setNotDirty: function(title) {
var me = this;
var userId = User.getCurActiveUserId();
Tags.update({UserId: userId, Title: title}, {$set: {IsDirty: false, UpdatedTime: new Date()}}, function() {
Tags.update({UserId: userId, Tag: title}, {$set: {IsDirty: false, UpdatedTime: new Date()}}, function() {
});
},
// 更新过来的, 本地有了, 要设置usn, 因为删除的时候要用
setNotDirtyAndUsn: function(title, usn) {
var me = this;
var userId = User.getCurActiveUserId();
Tags.update({UserId: userId, Tag: title}, {$set: {IsDirty: false, Usn: usn, UpdatedTime: new Date()}}, function() {
});
},