Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/owlycode/mongofixtures
A Go quick and dirty utility for cleaning collections and loading fixtures into them.
https://github.com/owlycode/mongofixtures
Last synced: about 1 month ago
JSON representation
A Go quick and dirty utility for cleaning collections and loading fixtures into them.
- Host: GitHub
- URL: https://github.com/owlycode/mongofixtures
- Owner: OwlyCode
- License: mit
- Created: 2013-09-09T17:26:50.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-10-23T23:18:07.000Z (over 11 years ago)
- Last Synced: 2024-06-20T12:19:50.441Z (7 months ago)
- Language: Go
- Size: 125 KB
- Stars: 2
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
mongofixtures [![Build Status](https://travis-ci.org/OwlyCode/mongofixtures.png)](https://travis-ci.org/OwlyCode/mongofixtures)
===============
A Go quick and dirty utility for cleaning collections and loading fixtures into them.How to install ?
----------------```bash
go get github.com/OwlyCode/mongofixtures
```How to use ?
------------```go
session, err := Begin("localhost", "database")
defer session.End()if err != nil {
panic(err)
}// Initial cleaning.
session.Clean("collection")// Now population time !
session.Push("collection", document{Id: bson.NewObjectId(), Title: "This is a demo"})// Load some yaml.
session.ImportYamlFile("test.yml")
```Note that Push and Clean can return both an error that you might want to check.
You can provide to the Begin function host parameter any string representing a mongo connection. For example : "mongodb://myuser:mypass@localhost" should work fine.
Notes on YAML
-------------/!\ The short notation for arrays [] is not supported at the moment. /!\
You can generate ids by using \_\_something\_\_. Every time mongofixtures sees a string matching \_\_(something)\_\_ it generates an ObjectId and stores it. If you use \_\_something\_\_ elsewhere mongofixtures will set the same ObjectId. Take a look a test.yml to view an example.
What's on the todo ?
--------------------
- More tests !
- Godoc the yml part
- Improve yml support