Coder Social home page Coder Social logo

mongo-haxe-driver's Introduction

MongoDB driver for Haxe

This is a database driver for MongoDB written in Haxe and available for all targets allowing a socket connection (neko/php/cpp).

Find all objects in a collection

Finding rows in a relational database can be a daunting process. Thankfully with Mongo it's just like accessing a regular Haxe object instance.

import org.mongodb.Mongo;

class Main
{
	public static function main()
	{
		var mongo = new Mongo();       // connects to MongoDB
		var posts = mongo.blog.posts;  // get the "blog.posts" collection

		// loops through all objects in "test.posts"
		for (post in posts.find())
		{
			trace(post.title); // assumes that all posts have a title
		}
	}
}

Inserting and updating

Inserting object in Mongo is just as simple as putting values in an Array. Just create an object and put it in the collection by calling insert(). Updating objects is just as simple except we need a way to find the original object so we pass a selector object first.

import org.mongodb.Mongo;

class Main
{
	public static function main()
	{
		var mongo = new Mongo();       // connects to MongoDB
		var posts = mongo.blog.posts;  // get the "blog.posts" collection

		// creating a new post is as easy as making a new object
		var post = {
			title: 'My awesome post',
			body: 'MongoDB is easy as pie'
		};
		posts.insert(post); // save the post in Mongo

		post.body = 'Made some updates to my post';
		posts.update({title: post.title}, post); // update the post
	}
}

Driver Roadmap

Here are the features planned for future versions.

** v0.9 **

  • Replica sets
  • Automatic reconnection

mongo-haxe-driver's People

Contributors

matttuttle avatar nambew avatar zlumer avatar

Watchers

 avatar  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.