亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

flask - MongoDB存儲(chǔ)的數(shù)據(jù),標(biāo)識(shí)怎樣在URL顯示的更簡(jiǎn)潔?
巴扎黑
巴扎黑 2017-04-22 08:59:58
0
5
757

Flask+MongoDB做的一個(gè)網(wǎng)站,文章管理塊,Mongodb中以O(shè)bjectId作的標(biāo)識(shí),當(dāng)瀏覽指定文章時(shí)現(xiàn)在以O(shè)bjectId作為標(biāo)識(shí),url形式如下:
/article/53219ebcbe238721a805d3fe/
ObjectId這截有沒有好辦法處理的更短,更優(yōu)雅些?

巴扎黑
巴扎黑

reply all(5)
阿神

Check this out: http://docs.mongodb.org/manual/tutorial/create-an-auto-incrementing-field/

伊謝爾倫

ObjectId has 12 bytes and a total of 96 bits of information. If hexadecimal is used, each bit can provide 6 bits of information, so only 16 64-bits are needed. There are 62 letters + numbers in total, just find two punctuation marks :-)

劉奇

You can use numbers to increase your ID
Mongodb officially provides a solution for self-increasing ID, please refer to

http://docs.mongodb.org/manual/tutorial/create-an-auto-incrementing-field/

The main principle is to create a new collection of counter counts in the database, record the maximum ID of each model, and then update the ID when saving. Use $inc in findAndModify to achieve increment. $inc is an atomic operation.

阿神

Create a new field to store the ID. When storing, take a screenshot.

Or use a customized Slug.

大家講道理

If it is an interface type, it will not be displayed directly in the browser address bar, so just use ObjectId.
If you are displaying an article, use: http://web/article/MongoDB存儲(chǔ)的數(shù)據(jù),標(biāo)識(shí)怎樣在URL顯示的更簡(jiǎn)潔 is better and easier for people to understand.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template