Skip to content

Instantly share code, notes, and snippets.

@wemgl
Last active February 4, 2019 01:56
Show Gist options
  • Save wemgl/d52cb54b127087c68f127133726100f0 to your computer and use it in GitHub Desktop.
Save wemgl/d52cb54b127087c68f127133726100f0 to your computer and use it in GitHub Desktop.
res, err := db.Collection(collName).InsertOne(ctx, bson.D{
{"task", t.Task},
{"createdAt", primitive.DateTime(timeMillis(t.CreatedAt))},
{"modifiedAt", primitive.DateTime(timeMillis(t.ModifiedAt))},
})
if err != nil {
return "", fmt.Errorf("createTask: task for to-do list couldn't be created: %v", err)
}
return res.InsertedID.(primitive.ObjectID).Hex(), nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment