java


MongoiDB use a String for _id


I'd like to use a unique string per collection to id a doc. I'm using Scala and Casbah but can also use Java if needed.
I know I should use Casbah collection.createIndex but I don't understand the scaladocs.
If my case class is :
case class GroupParams (
_id: String,
//groupId: String,
testPeriodStart: DateTime, // ISO8601 date
variants: Seq[String], //["17","18"]
testPeriodEnd: Option[DateTime])
and I will always use the _id to reference a particular document (no need for _id: ObjectId).
I don't care about sorting/ordering since these will only be accessed as individual docs, never cursored through. There seems no reason to have the overhead of another index on the default _id: ObjectId.
How to I create the index on the collection with _id: String using Casbah? If I should create a new index and leave the default alone can you show how to do this?
Mongo automatically creates index for _id field for all types (ObjectId, String or whatever you want) - mongo indexes
Mongo automatically generate a _id to your index in the collection,
if you want to insert String to the _id you can convert a String to objectId like this : ObjectId.Parse(myString))
See more in the MongoDB API

Related Links

ActiveMQ Unexpected failure from FailoverTransport
Null Pointer Exception JsonArray Size
User-enter values are not being stored properly
Generate Method Definition for button from XML onClick in Eclipse?
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.DisplayMessageActivity}
Randomly generating floats spanning the whole spectrum of valid floats
arraylist in self-designed class errors. please help me
Using scala map in Java
I am trying to get jersey and hibernate to work together
Unfortunately my app has stopped working
Applet php communication using POST
Change current working directory for each module in a reactor build?
How do i replace “\” with “\” [duplicate]
How to automatically expand a a4j:outputPanel?
Why is calling a function faster than not calling a function?
How make sure that singleton message driven bean processes one message at a time?

Categories

HOME
atom-editor
pypi
netbeans
fluentd
kde
office365api
gis
spring-jdbc
retrofit
mouse
ios-charts
multiple-records
append
add
facebook-php-sdk
ssl-client-authentication
kentor-authservices
postgres-xl
google-cloud-spanner
ibm-odm
quartz-scheduler
jsdoc
angular-ui
database-replication
contextmenu
grails3
clickonce
jquery-ajaxq
blazemeter
shopware
sparse-matrix
wpfdatagrid
fgetcsv
opentype
kendo-datasource
objectanimator
google-cloud-nl
gsoap
directx-10
geopositioning
cloud-code
serve
xenforo
az-application-insights
temporary-files
texmaker
node-gyp
firebase-admin
nomethoderror
wso2carbon
auto-update
osx-mavericks
appcompat
prolog-setof
hendrix
worksheet
dandelion
nodebb
crypt
libusb-win32
azure-sdk
multi-level
impresspages
firebaseui
lttng
captivenetwork
livequery
asp.net5
maven-tomcat-plugin
sankey-diagram
inmobi
rake-task
oxwall
uitouch
phpthumb
yorick
expected-exception
valuechangelistener
braille
fmod
jsctypes
sharp-repository
jelly
bitsharp
pysimplesoap
hosts-file
getmessage
parametric-equations
dotnethighcharts
jquery-ui-layout
nsdatecomponents
genshi
rfc1123
javax.script
file-comparison
pyinotify
iphone-web-app
coda-slider
web-application-design
wise
gamma
kdbg
simpletest
sustainable-pace
wsdl.exe
3gp

Resources

Encrypt Message