本文整理汇总了Java中org.jongo.Jongo.getCollection方法的典型用法代码示例。如果您正苦于以下问题:Java Jongo.getCollection方法的具体用法?Java Jongo.getCollection怎么用?Java Jongo.getCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jongo.Jongo
的用法示例。
在下文中一共展示了Jongo.getCollection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUser
import org.jongo.Jongo; //导入方法依赖的package包/类
public UserEntity createUser(String accountId, String username) {
JongoDBService manager = AppContext.getManager(JongoDBService.class);
Jongo jongo = manager.getJongo();
MongoCollection collection = jongo.getCollection("USER");
UserEntity userEntity = new UserEntity();
userEntity.setUserId(accountId);
userEntity.setAccountId(accountId);
userEntity.setLevel(1);
userEntity.setUserName(username);
try {
collection.insert(userEntity);
return userEntity;
} catch (com.mongodb.DuplicateKeyException e) {
}
return null;
}
示例2: getProfilingCollection
import org.jongo.Jongo; //导入方法依赖的package包/类
private MongoCollection getProfilingCollection() {
CollectorServerDto serverDto = ConfigReader.getCollectorServer();
;
try{
MongoDbAccessor mongo = new MongoDbAccessor(60000, true, serverDto.getAdminUser(), serverDto.getAdminPw(), serverDto.getHosts());
DB db = mongo.getMongoDB(serverDto.getDb());
Jongo jongo = new Jongo(db);
MongoCollection result = jongo.getCollection(serverDto.getCollection());
if(result == null) {
throw new IllegalArgumentException("Can't continue without profile collection for " + serverDto.getHosts());
}
return result;
} catch (MongoException e) {
LOG.error("Exception while connecting to: {}", serverDto.getHosts(), e);
}
return null;
}
示例3: selectOne
import org.jongo.Jongo; //导入方法依赖的package包/类
private void selectOne(){
Jongo jongo = new Jongo(dbconn.getDB(database));
org.jongo.MongoCollection mc = jongo.getCollection(collection);
JSONObject findField = (JSONObject)data.get("findField");
JSONObject sortField = (JSONObject)data.get("sortField");
JSONObject projectionField = (JSONObject)data.get("projectionField");
Find result = null;
if(findField != null){
result = mc.find(findField.toJSONString());
}
if(sortField != null){
result = result.sort(sortField.toString());
}
if(projectionField != null){
result = result.projection(projectionField.toString());
}
String resultJson = "";
org.jongo.MongoCursor cursor = result.as(Object.class);
if(cursor.hasNext()){
resultJson += cursor.next();
}
System.out.println(resultJson);
Response res= new Response(200, resultJson);
try {
res.writeData(client);
}
catch(IOException ioe){
System.out.println("[Error]" + ioe.getMessage());
}
}
示例4: getUser
import org.jongo.Jongo; //导入方法依赖的package包/类
public UserEntity getUser(String userId) {
JongoDBService manager = AppContext.getManager(JongoDBService.class);
Jongo jongo = manager.getJongo();
MongoCollection collection = jongo.getCollection("USER");
try {
UserEntity as = collection.findOne("{_id:#}", userId).as(UserEntity.class);
return as;
} catch (com.mongodb.DuplicateKeyException e) {
}
return null;
}
示例5: selectAccount
import org.jongo.Jongo; //导入方法依赖的package包/类
public AccountEntity selectAccount(String account,String password){
JongoDBService manager = AppContext.getManager(JongoDBService.class);
Jongo jongo = manager.getJongo();
MongoCollection collection = jongo.getCollection("Account");
try {
AccountEntity as = collection.findOne("{_id:#,accountPassWord:#}",account,password).as(AccountEntity.class);
return as;
} catch (com.mongodb.DuplicateKeyException e) {
}
return null;
}
示例6: regeditAccount
import org.jongo.Jongo; //导入方法依赖的package包/类
public AccountEntity regeditAccount(String account,String password){
JongoDBService manager = AppContext.getManager(JongoDBService.class);
Jongo jongo = manager.getJongo();
AccountEntity accountEntity=new AccountEntity();
accountEntity.setAccountName(account);
accountEntity.setAccountPassWord(password);
MongoCollection collection = jongo.getCollection("Account");
try {
collection.insert(accountEntity);
return accountEntity;
} catch (com.mongodb.DuplicateKeyException e) {
}
return null;
}
示例7: checkRegedit
import org.jongo.Jongo; //导入方法依赖的package包/类
public boolean checkRegedit(String account){
JongoDBService manager = AppContext.getManager(JongoDBService.class);
Jongo jongo = manager.getJongo();
MongoCollection collection = jongo.getCollection("Account");
AccountEntity findOne = collection.findOne("{_id:#}",account).as(AccountEntity.class);
return findOne!=null;
}
示例8: main
import org.jongo.Jongo; //导入方法依赖的package包/类
public static void main(String[] args) {
DB db = new MongoClient("192.168.0.199",32770).getDB("fly");
Jongo jongo = new Jongo(db);
AccountEntity accountEntity=new AccountEntity();
accountEntity.setAccountName("test2");
accountEntity.setAccountPassWord("1234");
MongoCollection collection = jongo.getCollection("Account");
try {
collection.insert(accountEntity);
} catch (com.mongodb.DuplicateKeyException e) {
System.out.println("1245");
}
AccountEntity as = collection.findOne("{_id:#,accountPassWord:#}","test2","12345").as(AccountEntity.class);
System.out.println(as);
}
示例9: selectUserByUserId
import org.jongo.Jongo; //导入方法依赖的package包/类
public UserEntity selectUserByUserId(Jongo jongo, String userId){
MongoCollection collection = jongo.getCollection("UserEntity");
try {
UserEntity as = collection.findOne("{_id:#}",userId).as(UserEntity.class);
return as;
} catch (com.mongodb.DuplicateKeyException e) {
return null;
}
}
示例10: selectUserByAccountId
import org.jongo.Jongo; //导入方法依赖的package包/类
public UserEntity selectUserByAccountId(Jongo jongo, String accountId){
MongoCollection collection = jongo.getCollection("UserEntity");
try {
UserEntity as = collection.findOne("{accountId:#}",accountId).as(UserEntity.class);
return as;
} catch (com.mongodb.DuplicateKeyException e) {
return null;
}
}
示例11: createUser
import org.jongo.Jongo; //导入方法依赖的package包/类
public boolean createUser(Jongo jongo ,UserEntity userEntity){
MongoCollection collection = jongo.getCollection("UserEntity");
try {
WriteResult insert = collection.insert(userEntity);
Object upsertedId = insert.getUpsertedId();
return true;
} catch (com.mongodb.DuplicateKeyException e) {
return false;
}
}
示例12: selectMany
import org.jongo.Jongo; //导入方法依赖的package包/类
private void selectMany(){
Jongo jongo = new Jongo(dbconn.getDB(database));
org.jongo.MongoCollection mc = jongo.getCollection(collection);
JSONObject findField = (JSONObject)data.get("findField");
JSONObject sortField = (JSONObject)data.get("sortField");
JSONObject projectionField = (JSONObject)data.get("projectionField");
Find result = null;
if(findField != null){
result = mc.find(findField.toJSONString());
}
if(sortField != null){
result = result.sort(sortField.toString());
}
if(projectionField != null){
result = result.projection(projectionField.toString());
}
String resultJson = "";
org.jongo.MongoCursor cursor = result.as(Object.class);
while(cursor.hasNext()){
resultJson += cursor.next();
}
System.out.println(resultJson);
Response res= new Response(200, resultJson);
try {
res.writeData(client);
}
catch(IOException ioe){
System.out.println("[Error]" + ioe.getMessage());
}
}
示例13: createPlaneEntity
import org.jongo.Jongo; //导入方法依赖的package包/类
public PlaneEntity createPlaneEntity(Jongo jongo ,String accountId,String userId){
PlaneEntity entity=new PlaneEntity();
MongoCollection collection = jongo.getCollection("PlaneEntity");
try {
collection.insert(entity);
return entity;
} catch (com.mongodb.DuplicateKeyException e) {
return null;
}
}
示例14: selectAccount
import org.jongo.Jongo; //导入方法依赖的package包/类
public AccountEntity selectAccount(Jongo jongo,String account,String password){
MongoCollection collection = jongo.getCollection("AccountEntity");
try {
AccountEntity as = collection.findOne("{_id:#,password:#}",account,password).as(AccountEntity.class);
return as;
} catch (com.mongodb.DuplicateKeyException e) {
return null;
}
}
示例15: regeditAccount
import org.jongo.Jongo; //导入方法依赖的package包/类
public AccountEntity regeditAccount(Jongo jongo ,String account,String password){
AccountEntity accountEntity=new AccountEntity();
accountEntity.setAccountId(account);
accountEntity.setPassword(password);
MongoCollection collection = jongo.getCollection("AccountEntity");
try {
collection.insert(accountEntity);
return accountEntity;
} catch (com.mongodb.DuplicateKeyException e) {
return null;
}
}