Then I have changed cells.js database on mangodeb server with local discount and all my ids have changed to a uuid id . General ID is very easy and cleaner. How can I change my ID again as integer ID?
What are the benefits of using btw UUID? And how do I request an update with that long ID?
{"name": "mutton", "id": "544a7968101ca2903974cdc1", "createdAt": "2014-10-24T16: 08: 08.052Z", "UpdateAut": "2014-10-24T 16: 08: 08.052Z"}
This " Normal "method that creates MongoDB id, is a combination of timestamp, machine identifier, process id and random values.
From the MongoDB site: "Documents stored in a collection require a unique _id field which acts as the primary key. Since ObjectIds are small, most likely is unique, and Fast to generate "
The primary key and probably some other data are related to them.
If you want to keep the id like 1,2,3,4,5 ... you have to set up your generation and save the id you make the model:
User.create ({_ ID: 1, name: 'John'});
You can update with a "short" ID via the Blueprint API as well:
PUT / user / 544a7968101ca2903974cdc1
< / Pre>and submit a new data to a form or ajax.
Update a value on an existing model example:
var postId; // Create a blog post for example $. AJX ({url: '/ post', method: 'post', // create a new entry in the DB data: {title: 'Untitled Post', text: 'example blog Post '}, success: function (data) {// data = {id:' randomGeneratedId ', title:' untitled post ', text:' example blog post '} postId = data.id;}}); // later ... update this post in $ .adse ({url: '/ post /' + post id, method: 'put', // db data: {image: 'path / to / image. Jpg '}, success: work (data) {// data = {id:' randomGeneratedId ', image:' path / to / image.jpg ', title:' untitled post ', text:' example blog post '}} });
Comments
Post a Comment