V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  XTTX  ›  全部回复第 35 页 / 共 43 页
回复总数  842
1 ... 27  28  29  30  31  32  33  34  35  36 ... 43  
2021-10-24 23:45:50 +08:00
回复了 balabalaguguji 创建的主题 Go 编程语言 看到 Go 与 MongoDB 的交互方式,我想放弃 Go 了
不清楚为什么贴主一定要用 mongoDB 。Go 写 psql query 挺方便的,写多了都是 boilerplate, 改改就差不多了
2021-10-24 23:39:31 +08:00
回复了 balabalaguguji 创建的主题 Go 编程语言 看到 Go 与 MongoDB 的交互方式,我想放弃 Go 了
JS 写成 typescript ,要写各式各样的 type\interface\generics, 可不必 Go 写 struct 方便多少。
2021-10-24 22:31:53 +08:00
回复了 tiensonqin 创建的主题 酷工作 Logseq 远程招聘一位开发工程师 [40k ~ 65k]
@waytoexplorewhat 还是不要在别人的招聘贴里问这些东西。既然别人拿到了投资自然有对策。
2021-10-24 14:47:46 +08:00
回复了 balabalaguguji 创建的主题 Go 编程语言 看到 Go 与 MongoDB 的交互方式,我想放弃 Go 了
@Kisesy 我猜当初设计的时候,mongoDB 就是要做 data warehouse,所以必须读 ctx withTimeout 。mongoDB 的市场营销是所有 tech 里做得最好的, 让所有人都觉得其他人都在用 mongoDB 。 官网的文档那叫一个省事,复杂一点的查询方式根本不介绍。 当初我找查询的语法,真的找到吐血。
2021-10-24 13:39:57 +08:00
回复了 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 13:34:26 +08:00
回复了 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 13:33:26 +08:00
回复了 balabalaguguji 创建的主题 Go 编程语言 看到 Go 与 MongoDB 的交互方式,我想放弃 Go 了
官方 doc 就劝退了, 那你还是千万别用 go+mongoDB 了
2021-10-21 18:38:10 +08:00
回复了 XTTX 创建的主题 Go 编程语言 Golang 中的 web app error 处理
@NeroKamin 肯定不是啊。3.0 就要出了, 你找作者聊聊
你以为库克会害你吗?狗头。。。。。
@binbin0915 我说的是玩游戏
再置办个显卡。。。 继续划水。 不知道国内的 cloud ide 做得怎么样了,各大厂都再搞
2021-10-19 22:37:46 +08:00
回复了 kernel365 创建的主题 酷工作 [远程全职]全栈工程师(Vue, NodeJs, Python )
@darkengine 业务能力强啊。不过既然没有 Tech lead, 技术选型可以打破重来。
2021-10-19 20:11:24 +08:00
回复了 Canace 创建的主题 程序员 台式电脑有推荐的的吗
@wasd6267016 4 月左右的我用了 4 年的 1080ti 挂 5250 被秒了, 现在也就中正这种整机销售商能优先拿到好的价格了。
2021-10-19 20:01:09 +08:00
回复了 XTTX 创建的主题 求职 React,Golang 全栈求职
@mimang518 可以啊。 给个联系方式聊聊
2021-10-19 15:13:33 +08:00
回复了 Canace 创建的主题 程序员 台式电脑有推荐的的吗
@wasd6267016 8299,升级一下 cpu 或者价格 1tb 的 ssd 就到 1 万了。 显示器可以攒点钱买个 34 寸的 2k 。
2021-10-19 13:29:20 +08:00
回复了 Canace 创建的主题 程序员 台式电脑有推荐的的吗
@Deteriorator 今年的行情,自己组根本找不到价格合适的显卡。
2021-10-19 13:28:43 +08:00
回复了 Canace 创建的主题 程序员 台式电脑有推荐的的吗
lz 可以去 b 站搜 中正评测, 看看他家的配置和价格做对比。3070,1 万内应该可以搞定。 再往上性价比也不高了
2021-10-18 22:47:29 +08:00
回复了 sunkai0609 创建的主题 Go 编程语言 Golang sync.Map tryLoadOrStore 函数看不懂其中的 ic := i
@bruce0 谢谢回复。 有空了我多了解一下这方面的知识。
栈方便说一下吗
2021-10-18 18:30:19 +08:00
回复了 sunkai0609 创建的主题 Go 编程语言 Golang sync.Map tryLoadOrStore 函数看不懂其中的 ic := i
@bruce0 我是真的没有弄明白为什么要用 ic: = i 。· tryLoadOrStore(i interface{}) · 这里用的应该是 value semantic, i 是一个新的拷贝才对。 这是我的理解, 不对的地方请指出。
1 ... 27  28  29  30  31  32  33  34  35  36 ... 43  
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   5642 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 29ms · UTC 01:44 · PVG 09:44 · LAX 17:44 · JFK 20:44
♥ Do have faith in what you're doing.