https://github.com/dasfmi/shorba
https://github.com/dasfmi/shorba
dummy fixtures go mongodb
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/dasfmi/shorba
- Owner: dasfmi
- Created: 2016-04-25T19:32:02.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-11-13T12:06:28.000Z (over 9 years ago)
- Last Synced: 2025-02-14T05:19:53.440Z (over 1 year ago)
- Topics: dummy, fixtures, go, mongodb
- Language: Go
- Size: 5.86 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#Shorba
Shorba is a small tool to generate dummy/fake data in Go based on struct (serving as model) and insert those data into mongodb.
let's suppose you have a struct like that:
type Post struct {
ID string `bson:"_id,omitempty"`
Title string `bson:"title"`
Content string `bson:"content"`
PublishDate time.Time `bson:"publishDate"`
}
and you want to populate 200 fake posts for testing and develpoment purposes,
you can use shorba to do that for you, like this:
postModel := &Post{}
shorba.populate("posts", &postModel, 200)
this should generate 200 different posts and insert them into collection 'posts'
####Usage
first install shorba
go get github.com/eslammostafa/shorba
import it
import (
...
"github.com/eslammostafa/shorba"
)
connect to your mongodb
shorba.Connect("localhost", "username", "password", "dbname")
if there is no username nor password write "" instead of each one
shorba.Connect("localhost", "", "", "dbname")
populate data
postModel := &Post{}
shorba.populate("posts", &postModel, 135)
#### TODO
* Support arrays
* Support Embedded Documents