node.js - Create hashid based on mongodb '_id` attribute -


i have mongo db schema follows:

var mytable = mongoose.model('items', {     name: string,     keyid: string }); 

i store keyid hashid of '_id' item being created. eg. say, add item db "hello world", , mongodb create '_id' item while inserting.

i make use of _id use , generate hashid same item being inserted. this:

var hashids = require("hashids"),     hashids = new hashids("this salt");  var id = hashids.encrypt("507f191e810c19729de860ea"); 

is there way, know id before hand. or let mongodb generate value id field based on criteria specify.

just note on this. hashids module has encrypthex (or encodehex in v1.x), intended use mongodb ids.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -