MongoDB ODM Framework mongomongo-simplify your data storage

Source: Internet
Author: User
Tags mongodb

Mongmongo is a Java-written ODM framework, making the operation of MongoDB more convenient.

Mongomongo strives to provide Java developers with an operational API similar to Activeorm or hibernate, and retains MongoDB's schemaless,document-based design, dynamic query, and atomic modification operations. Of course, you can easily bypass Mongomongo and use the Java Driver functionality provided by the native.

The following is a sample code:

[Java]  View plain copy public class blog extends document {        static {           storein ("blogs");                             hasmanyembedded ("Articles",  new options (map                     options.n_kclass,  Article.class           ));            //create index            index (Map ("Blogtitle",  -1),  map (unique,true));            //validate uerName field            Validate ("UserName ", Map (Length,map                     minimum,5           ));          }       //association related        public associationembedded articles ()  {throw new  Autogeneration ();}        private String userName;        private string blogtitle;  }      public class article  extends document {       static {                    belongstoembedded ("blog",  New options (Map (                    options.n_kclass, blog.class           )) ;       }       public associationembedded  blog ()  {throw new autogeneration ();        private String title;       private  String body;  }      public class usage{      public static void main (String[] args) {            blog blog = blog.where (Map ("UserName", "Sexy java")). In (Map ("id", List (1,2,3)). Singlefetch ();        blog.articles (). Build (Map ("title", "i am  Title "," Body "," i am body ");        blog.save ();      }     }  

We can see that this is a typical congestion model. associating, storing, creating indexes, setting aliases, and so on, simply call a function in the static block to achieve it. If you use some dynamic language, you will find that this method-level declarative syntax is very popular and very comfortable to write.

In fact, there are many frameworks related to MongoDB, so the advantages of Mongomongo. We can simply make a comparison of the code at a glance.

For example, Springdata for MongoDB, the typical operation is as follows:

[Java]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.