php - Is it possible to control MongoId generation? -


here scenario. storing entries in mongodb , using _id public identifier each entry when fetching them display. since _id hard guess , therefore user access 1 entry based on _id in url can not guess next or previous entry (except example below) based on information. not have create indexes on field containing md5 hash or uniqid example.

the problem: when creating multiple entries part of import job, entries similar _id´s due fact partly based on timestamp. 3 entries created during import can example. 52014b1a3c9fb7733d000000 52014b1a3c9fb7733d000001 52014b1a3c9fb7733d000002

in scenario, user might see pattern , try edit last part of each identifier, , succeed in viewing entry in case.

my question(s): possible control mongoid generation upon document creation not use increment function @ end when creating large amount if entries import example? changing device part of id? can done?

my last resort stop using _id public identifier entries, forcing me set additional indexes on large collection. hope not have go there.

i using mongodb in php based application.

you can't change automatic id generation it's set algorithm drivers have use. can create own idea yourself, have each document:

<?php $document = array(     "_id" => new mongoid("ffb234234...."); ); 

you need make sure pass 24 hex chars constructor of mongoid format set. however, if this, please make sure include pid , hash(hostname) can guarantee uniqueness among more 1 machine , process.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -