Created
October 24, 2021 17:01
-
-
Save codenoid/37e39a475ce0f3dbcfd1f6e4d280d565 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"time" | |
"github.com/qiniu/qmgo" | |
"gopkg.in/mgo.v2/bson" | |
) | |
func main() { | |
ctx := context.Background() | |
client, err := qmgo.NewClient(ctx, &qmgo.Config{Uri: "mongodb://localhost:27017"}) | |
if err != nil { | |
panic(err) | |
} | |
db := client.Database("qmgo_date_test") | |
coll := db.Collection("test") | |
// coll.InsertOne(context.TODO(), bson.M{"date": time.Now(), "text": "hello"}) | |
var item bson.M | |
coll.Find(context.TODO(), bson.M{"date": bson.M{"$lt": time.Now()}}).One(&item) | |
fmt.Println(item) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment