V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
V2EX  ›  XTTX  ›  全部回复第 49 页 / 共 56 页
回复总数  1118
1 ... 41  42  43  44  45  46  47  48  49  50 ... 56  
❮ ❯
2021 年 10 月 24 日
回复了 balabalaguguji 创建的主题 › Go 编程语言 › 看到 Go 与 MongoDB 的交互方式,我想放弃 Go 了
````
//FindFinishedListArticleAction finds if articleAction exists by checking articleId and ownerID
func (aam *articleActionDB) FindFinishedListArticleAction(ownerID primitive.ObjectID) (*[]Article, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

client, err := mongo.Connect(ctx, options.Client().ApplyURI(aam.connectionString))
if err != nil {
return nil, err
}
defer client.Disconnect(ctx)
collection := client.Database(aam.dataBaseName).Collection(aam.collectionName)
matchStage := bson.D{{"$match", bson.M{"ownerID": ownerID}}}
matchStage1 := bson.D{{"$match",
bson.M{"finisheddate": bson.M{"$exists": true}}}}
projectStage := bson.D{{"$project", bson.M{"articleID": 1}}}

type articleID struct {
ArticleID primitive.ObjectID `bson:"articleID"`
}

var articleIDs []articleID

cursor, err := collection.Aggregate(ctx, mongo.Pipeline{matchStage, matchStage1, projectStage})
if err != nil {
fmt.Println(err)
return nil, err
}
if err = cursor.All(ctx, &articleIDs); err != nil {
return nil, err
}
articleClient, err := mongo.Connect(ctx, options.Client().ApplyURI(aam.connectionString))
if err != nil {
return nil, err
}
defer articleClient.Disconnect(ctx)
articleCollection := client.Database("crawler").Collection("article")
var articles []Article
var article Article
for i := 0; i < len(articleIDs); i++ {
err := articleCollection.FindOne(ctx, bson.M{"_id": articleIDs[i].ArticleID}).Decode(&article)
if err != nil {
fmt.Println(err)
}
articles = append(articles, article)
}
return &articles, nil
}
````

这种东西写的难受, 看得更难受。
2021 年 10 月 24 日
回复了 balabalaguguji 创建的主题 › Go 编程语言 › 看到 Go 与 MongoDB 的交互方式,我想放弃 Go 了
//FindReadingListArticleAction finds if articleAction exists by checking articleId and ownerID
func (aam *articleActionDB) FindUserArticleActionArticle(ownerID primitive.ObjectID) (*[]Article, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

client, err := mongo.Connect(ctx, options.Client().ApplyURI(aam.connectionString))
if err != nil {
return nil, err
}
defer client.Disconnect(ctx)
collection := client.Database(aam.dataBaseName).Collection(aam.collectionName)
matchStage := bson.D{{"$match", bson.M{"ownerID": ownerID}}}
projectStage := bson.D{{"$project", bson.M{"articleID": 1}}}

type articleID struct {
ArticleID primitive.ObjectID `bson:"articleID"`
}

var articleIDs []articleID

cursor, err := collection.Aggregate(ctx, mongo.Pipeline{matchStage, projectStage})
if err != nil {
fmt.Println(err)
return nil, err
}
if err = cursor.All(ctx, &articleIDs); err != nil {
return nil, err
}
articleClient, err := mongo.Connect(ctx, options.Client().ApplyURI(aam.connectionString))
if err != nil {
return nil, err
}
defer articleClient.Disconnect(ctx)
articleCollection := client.Database("crawler").Collection("article")
var articles []Article
var article Article
for i := 0; i < len(articleIDs); i++ {
err := articleCollection.FindOne(ctx, bson.M{"_id": articleIDs[i].ArticleID}).Decode(&article)
if err != nil {
fmt.Println(err)
}
articles = append(articles, article)
}
return &articles, nil
}

我 6 个月前写的,我现在完全看不懂当初写了什么寂寞
2021 年 10 月 24 日
回复了 balabalaguguji 创建的主题 › Go 编程语言 › 看到 Go 与 MongoDB 的交互方式,我想放弃 Go 了
官方 doc 就劝退了, 那你还是千万别用 go+mongoDB 了
2021 年 10 月 21 日
回复了 XTTX 创建的主题 › Go 编程语言 › Golang 中的 web app error 处理
@NeroKamin 肯定不是啊。3.0 就要出了, 你找作者聊聊
你以为库克会害你吗?狗头。。。。。
@binbin0915 我说的是玩游戏
再置办个显卡。。。 继续划水。 不知道国内的 cloud ide 做得怎么样了,各大厂都再搞
2021 年 10 月 19 日
回复了 kernel365 创建的主题 › 酷工作 › [远程全职]全栈工程师(Vue, NodeJs, Python )
@darkengine 业务能力强啊。不过既然没有 Tech lead, 技术选型可以打破重来。
2021 年 10 月 19 日
回复了 Canace 创建的主题 › 程序员 › 台式电脑有推荐的的吗
@wasd6267016 4 月左右的我用了 4 年的 1080ti 挂 5250 被秒了, 现在也就中正这种整机销售商能优先拿到好的价格了。
2021 年 10 月 19 日
回复了 XTTX 创建的主题 › 求职 › React,Golang 全栈求职
@mimang518 可以啊。 给个联系方式聊聊
2021 年 10 月 19 日
回复了 Canace 创建的主题 › 程序员 › 台式电脑有推荐的的吗
@wasd6267016 8299,升级一下 cpu 或者价格 1tb 的 ssd 就到 1 万了。 显示器可以攒点钱买个 34 寸的 2k 。
2021 年 10 月 19 日
回复了 Canace 创建的主题 › 程序员 › 台式电脑有推荐的的吗
@Deteriorator 今年的行情,自己组根本找不到价格合适的显卡。
2021 年 10 月 19 日
回复了 Canace 创建的主题 › 程序员 › 台式电脑有推荐的的吗
lz 可以去 b 站搜 中正评测, 看看他家的配置和价格做对比。3070,1 万内应该可以搞定。 再往上性价比也不高了
2021 年 10 月 18 日
回复了 sunkai0609 创建的主题 › Go 编程语言 › Golang sync.Map tryLoadOrStore 函数看不懂其中的 ic := i
@bruce0 谢谢回复。 有空了我多了解一下这方面的知识。
栈方便说一下吗
2021 年 10 月 18 日
回复了 sunkai0609 创建的主题 › Go 编程语言 › Golang sync.Map tryLoadOrStore 函数看不懂其中的 ic := i
@bruce0 我是真的没有弄明白为什么要用 ic: = i 。· tryLoadOrStore(i interface{}) · 这里用的应该是 value semantic, i 是一个新的拷贝才对。 这是我的理解, 不对的地方请指出。
2021 年 10 月 15 日
回复了 partystart 创建的主题 › 求职 › 就有点郁闷啊 关于面试米哈游工作的事情
都发出来了还有什么同不同意的
2021 年 10 月 14 日
回复了 nanmu42 创建的主题 › Go 编程语言 › Go 1.18 泛型会来,但官方库支持可能得等等
@surbomfla <贬低其他语言 ,抬高自己用的语言和 tooling> 提供了程序员日常 15%的所有乐趣
2021 年 10 月 14 日
回复了 nanmu42 创建的主题 › Go 编程语言 › Go 1.18 泛型会来,但官方库支持可能得等等
为什么编程都要搞政治正确这种浪费时间的事,github 从 master 该成 main 就浪费了不少宝贵生命,它礼貌吗?它正确吗?
2021 年 10 月 14 日
回复了 nanmu42 创建的主题 › Go 编程语言 › Go 1.18 泛型会来,但官方库支持可能得等等
@kidlj 应该有不少人不知道 import "github.com/dimfeld/httptreemux" 和 import "github.com/dimfeld/httptreemux/v5" 的区别。只能说和常用的 npm 太不同了
1 ... 41  42  43  44  45  46  47  48  49  50 ... 56  
❮ ❯
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2095 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 38ms · UTC 05:07 · PVG 13:07 · LAX 21:07 · JFK 00:07
♥ Do have faith in what you're doing.