2014-03-13 33 views
0

有人可以给我一个用morphia和mongodb进行映射的代码示例吗? 这是我的班,其中包含数据库字段。我不知道如何 使吗啡和mongodb之间的联系。如何从mogodb创建类

import com.google.code.morphia.annotations.*; 

//@Entity 
//define the name of the collection where this entity will be stored 

@Entity("tabes") 
class MappingMorphia { 
    @Id 
    String id; 

    String FACILITY; 
    String HOST; 
    String MESSAGE; 
    String PID; 
    String PRIORITY; 
    String PROGRAM; 
    int SEQNUM; 
    String SOURCE; 
    String SOURCEIP; 
    String TAGS; 

    //getters and setters 
} 

回答

0

Mongodb不了解类,或者至少不是你所想的。然而,有一个叫mongoose的模块可以让你的模型成为你的对象。我认为这将适合你。

下面是猫鼬的文档的链接

http://mongoosejs.com/docs/documents.html

+1

他用吗啡(或试图),使对象模型的工作就好了。 – evanchooly

+0

在这里,有我的喜欢 – lascort