Coder Social home page Coder Social logo

rocknrollmarc / mongofixtures Goto Github PK

View Code? Open in Web Editor NEW

This project forked from owlycode/mongofixtures

0.0 1.0 0.0 128 KB

A Go quick and dirty utility for cleaning collections and loading fixtures into them.

License: MIT License

Go 100.00%

mongofixtures's Introduction

mongofixtures Build Status

A Go quick and dirty utility for cleaning collections and loading fixtures into them.

How to install ?

go get github.com/OwlyCode/mongofixtures

How to use ?

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

mongofixtures's People

Contributors

owlycode avatar

Watchers

RocknrollMarc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.