java - How to send a mongodb shell function on jongo insert functions -
I am trying to use a MongoDB shell function, such as date (), a jongo driver function on my files The code is as follows:
collection.insert ("{date: date ()}"); But does this seem to work?
These errors are
exception in the thread "main" org.bson.io.PoolOutputBuffer.write (PoolOutputBuffer.java:89) org.bson.LazyBSONObject.pipe At java.lang.System.arraycopy (Native Method) on java.lang.ArrayIndexOutOfBoundsException (LazyBSONObject.java:474) com. On com.mongodb.InsertCommandMessage.writeTheWrites (InsertCommandMessage.java45) at com.mongodb.BSONBinaryWriter.encodeDocument (BSONBinaryWriter.java:339) on org.jongo.bson.BsonDBEncoder.writeObject (BsonDBEncoder.java39). Com.mongodb.BaseWriteCommandMessage.encodeMessageBody (at BaseWriteCommandMessage.java) at com.mongodb.RequestMessage.encode com.mongodb.baseWriteCommandMessage.encodeMessageBody (BaseWriteCommandMessage.java:69) at mongodb.InsertCommandMessage.writeTheWrites (InsertCommandMessage.java.2) (RequestMessage .java: 66) at com.mongodb BaseWriteCommandMessage.encode (BaseWriteCommandMessage.java:53) com.mongodb.DBCollectionImpl.sen at com.mongodb.DBCollectionImpl.writeWithCommandProtocol (DBCollectionImpl.java:427) com.mongodb.DBCollectionImpl.insertWithCommandProtocol (DBCollectionImpl.java387) com.mongodb. DBCollectionImpl.insert at DWriteCommandMessage (DBCollectionImpl.java:473) (com.mongodb.DBCollectionImpl.insert at DBCollectionImpl.jert: com) (DBCollectionImpl.java:165) com.mongodb.DBCollection.insert (DBCollection.java:161) com.mongodb At least 186 in .dbcollection.insert (DBCollection.java:107) .mongodb.DBCollection.save at org.jongo.Insert.save (Insert.java:49) (DBCollection.java:966) org.jongo.MongoCollection .save (MongoCollection.java:128) at learningjongo.DAO.setUp (DAOJava42)
I recommend that you do
collection.insert ("{date: #}", new java.util.Date ()); This is equivalent to {date: ISODate ()} or {date: new date (}} . something like the pre> archive .inert ("{date: #}", new java.util.Date (.) ToString ()); But if you have a choice, then I would suggest that you keep it as a proper date, and not a string.
Comments
Post a Comment