import ( "github.com/mongolar/mongolar/wrapper" ) func main() { dbInstance := wrapper.NewWrapperServe("localhost", "mydb") // Use dbInstance to interact with the database }
import ( "github.com/mongolar/mongolar/wrapper" "go.mongodb.org/mongo-driver/bson/primitive" ) type User struct { ID primitive.ObjectID `bson:"_id,omitempty"` Name string `bson:"name"` Email string `bson:"email"` Password string `bson:"password"` } func main() { dbInstance := wrapper.NewWrapperServe("localhost", "mydb") newUser := User{ Name: "John Doe", Email: "[email protected]", Password: "mysecretpassword", } result, err := dbInstance.InsertData("users", newUser) if err != nil { // Handle error } // Use result to find the inserted document's ID }
import ( "github.com/mongolar/mongolar/wrapper" ) func main() { dbInstance := wrapper.NewWrapperServe("localhost", "mydb") // Find all documents in the "users" collection users, err := dbInstance.FindData("users", nil) if err != nil { // Handle error } // Use "users" to iterate over the results }Overall, the go github.com.mongolar.mongolar.wrapper package provides a simple but powerful way to interact with MongoDB databases using Go code.