小编dyz*_*010的帖子

如何将Node.js制作的网站发布到Github Pages?

我使用Node.js作为服务器创建了一个网站.我知道,node.js文件应该通过在终端中键入命令开始工作,所以我不确定Github Pages是否支持node.js-hosting.所以我该怎么做?

node.js github-pages

88
推荐指数
3
解决办法
7万
查看次数

使用带golang的mgo无法检索"_id"值

这是我的结构定义:

type Article struct {
    Id      bson.ObjectId `json:"id"        bson:"_id,omitempty"`
    Title   string        `json:"title"`
    Author  string        `json:"author"`
    Date    string        `json:"date"`
    Tags    string        `json:"tags"`
    Content string        `json:"content"`
    Status  string        `json:"status"`
}
Run Code Online (Sandbox Code Playgroud)

这是我从数据库中获取数据的方法:

func AllArticles() []Article {
    articles := []Article{}
    err := c_articles.Find(bson.M{}).All(&articles)
    if err != nil {
        panic(err)
    }

    return articles
}
Run Code Online (Sandbox Code Playgroud)

这是存储在数据库中的一个对象:

{ "_id" : ObjectId( "5281b83afbb7f35cb62d0834" ),
  "title" : "Hello1",
  "author" : "DYZ",
  "date" : "2013-11-10",
  "tags" : "abc",
  "content" : "This is another content.",
  "status" : "published" }
Run Code Online (Sandbox Code Playgroud)

这是打印结果:

[{ObjectIdHex("") …
Run Code Online (Sandbox Code Playgroud)

go mongodb mgo

21
推荐指数
3
解决办法
2万
查看次数

标签 统计

github-pages ×1

go ×1

mgo ×1

mongodb ×1

node.js ×1