func (b *BaseData) CleanData(t time.Time) { daysAgo20 := t.AddDate(0, 0, -20) err := db.Remove(DB, C_REQUEST, bson.M{"time": bson.M{"$lt": daysAgo20}}) if err != nil && !strings.Contains(err.Error(), "not found") { log.Error(err) } }
func (m *TopicMgr) DoDelete(t time.Time) { m.lock.Lock() defer m.lock.Unlock() for _, topic := range m.DeleteTopics { if topic.NeedDelete.AddDate(0, 0, 2).Before(t) { db.Remove(DB, C_TOPIC, bson.M{"id": topic.ID}) } } }
func (m *TopicMgr) ImmeDelTopic(topic *Topic) error { m.lock.Lock() defer m.lock.Unlock() err := db.Remove(DB, C_TOPIC, bson.M{"id": topic.ID}) if err == nil { delete(m.DeleteTopics, topic.ID) topic = nil } return err }