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

node.js - How to mock a third-party api calls in the backend -

java - Could not locate OpenAL library -

Non Unique Username with ASP.Net Identity 2.0 -