Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

o-m-m

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

o-m-m

Omm maps between rich objects and documents.

  • 0.0.31
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Meteor object mapper

Omm maps between rich objects and documents.

Key features

  • Load rich objects instead of documents from a collection

  • Describe the object graph through annotation-style function calls

  • Declare meteor methods through annotations-style function calls

  • Perform collection altering operations anywhere on the object graph

  • Strengthens encapsulation of objects by removing persistence logic from the domain logic

  • Atomicity over complex operations within one document

Api Documentation

JsDoc

Example

Garden.js

Garden = function Garden( name, id ){
	this._id = id;
	this.name = name;
	this.plants = [];
	this.harvested = 0;
};
// declares Garden as an Entity
omm.addEntity(Garden);
// declares that the property "plants" contains objects of the type "Plant"
omm.arrayType(Garden, "plants", "Plant");

Garden.prototype.addPlant = function( t ){
	this.plants.push( new Plant( t, this ) );
};
omm.collectionUpdate( Garden, "addPlant" );

Garden.prototype.growPlants = function(){
	this.plants.forEach( function(p){
		p.grow();
	});
};
omm.collectionUpdate( Garden, "growPlants" );

Plant.js

Plant = function Plant( type, garden ){
	//this._id = "id"+garden.plants.length;
	this.type = type;
	this.height = 1;
	this.garden = garden;
};
// declares that Plant is an Entity
omm.addEntity(Plant);
// declares that the property garden contains object of the class "Garden"
omm.type(Plant, "garden", "Garden");
// declares that the value of the property should be stored as a key (string) rather than the actual object
omm.asForeignKey(Plant, "garden");


Plant.prototype.grow = function(){
	if( this.height<20 )
		this.height++;
	if( this.height==10 || this.height==15 ){
		this.garden.addPlant(this.type,this.garden);
	}
};

Plant.prototype.harvest = function(){
	var i = this.garden.plants.indexOf(this);
	this.garden.plants.splice(i,1);
	this.garden.harvested+=this.height;
};
// declares that the function "harvest" should also be invoked on the object in the collection.
omm.collectionUpdate( Plant, "harvest");

License

MIT

FAQs

Package last updated on 19 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc