The question I have is that I'm trying to auto-generate a number incrementally every time a user creates a new record. I'm trying to have the field auto-generate a number as soon as a person wants to create a new record and have it be uneditable or greyed out.
I've been looking into angular material to see if this can be done on the front end, but I'm not sure.
Normally it is a responsibility of back-end to generate such a number which uses as an identifier or id. How does back-end generate it depends on Database, for example MongoDB generate UUID and add it to your object.
but if you insist to make it in front-end on purpose you can use uuid npm package.
import { v4 as uuidv4 } from 'uuid';
const uuid = uuidv4();
Related
I'm building a studying tool that essentially consists of multiple flashcards (in the thousands). I would like to know if there is a unique way or method where the prewritten flashcards can be duplicated and tied to every user who signs up? Or perhaps having the data prewritten inside a JSON file and then upon user creation having it imported into MongoDB with a userID field that the data becomes unique to every individual user. The reason for this is because the flashcards will be using a spaced repetition algorithm and as a result I can't have one users results be carried over globally for every user. It would need to be unique to that user.
Thanks in advance for any help!
So far I've built the flashcard model and tied it to the algorithm however it updates globally across all users. Im havign a bit of trouble with breaking down some of the logic to make it unique to each user.
I'm currently trying to get localized data for one specific instance of a Collection Type.
Let's say I have a Collection Type called Project.
If I want to get all Projects in french I just need to call the exposed endpoint myApi/projects with the parameter _locale=fr myApi/projects?_locale=fr and it's working pretty well.
But if I try to get one specific project for example myApi/projects/1?_locale=fr it returns a 404 not found.
By the way, myApi/projects/1 return the project but in the default locale which is english.
Thanks for helping me.
Localized entries on collection types are considered as a separate entry, rather than a "localized version of the entry". i.e. myApi/projects/1's french version will have a different id, such as myApi/projects/7.
To see which id corresponds with which language, call myApi/projects?locale=<lang>.
My service is built using Node + Loopback + Mongo.
I would like to drop the db at the startup if and only if at least one of the following two asserts is true:
any model schema has changed (note that I cannot use isActual() because that's usable only with relational DBs)
new data has been added/removed from the default data-set definition files (data folder)
I'm currently versioning the db using a custom logic comparing version table and a version unique var but I wonder if there is an easy way to check the two asserts above.
Any idea? Ty
I have migrated the data from Mysql to ElasticSearch, then I found that elasticSearch default is analyzed on string. Now I want to change some string fields from analyzed to not-analyzed. which we cannot change directly from elasticsearch. what will be the optimal way to change it without deleting the data? or Should first I backup the elasticSearch data, then create new index with mapping and then migrate from old to new one.
Well , the only option here would be to backup data , create new index with updated mapping and re indexing the entire set of documents to the new one. Elasticsearch produces a great deal of meta data based on the data that you provide on which the search happens. This needs to be regenerated and only way is reindexing.
Is it possible for a Javascript client create a UUID that cannot be faked?
For example, suppose one of the solutions from Create GUID / UUID in JavaScript? were used to generate a UUID and send a create request with UUID to the server. Is it possible for the server to check that the UUID was indeed created by the Javascript function and not by some other function?
One idea is to use a checksum, but the UUID generation and checksum code would be visible to a "hacker". They could simply modify the Javascript function and then add the checksum.
So, are there any good solutions to this problem?
You shouldn't care about who created the UUID. The server should only check if the UUID sent by the client respects the UUID format and perhaps check if somehow the same UUID was used already (this depends on your needs).
That is unless your UUID value is used as a secret (e.g. an activation number). In this case, the value shouldn't be generated client-side and the server should keep track of the values it generated.
You can do some basic sanity checks like length or format, but what you are actually asking is "Given a number can I check that it was generated by a particular random number generator?". If the random number generator is truly random then the answer has to be "no", since if I can back-track from the answer to the function that easily then it's not very random.