I want to know if it is possible to create custom fields only once and use them through out multiple entities. For instance if I want to have a field called "Partner" and have it in Leads, Opportunities and Account. Can I just create the field only once and have it accessed in three different entities?
Thanks in advance
Yes and no. You'll need to create the field on each entity but you can share the data between them.
One way is a shared option set. This lets you manage one list of items and use it over and over on different entities. Another way you could go about it is to have a new entity for the data you're storing, and instead of creating a field you create a lookup to that record. This would be good if you had a list of countries that you wanted to reference all over CRM.
Related
I'm currently trying to build a web app that would allow many users to query an external API (I cannot retrieve all the data served by this API at regular intervals to populate my PostgreSQL database for various reasons). I've read several thing about ACID and MVCC but still, I'm not sure there won't be any problem if several users are populating/reading my PostgreSQL database at the very same time. So here I'm asking for advice (I'm very new to this field)!
Let's say my users query the external API to retrieve articles. They make their search via a form, the back end gets it, queries the api, populates the database, then query the database to return some data to the front end.
Would it be okay to simply create a unique table to store the articles returned by the API when users are querying it ?
Shall I rather store the articles returned by the API and associate each of them to the user that requested it (the Article model will contain a foreign key mapping to a User model)?
Or shall I give each user a table (data isolation would be good but that sounds very inefficient)?
Thanks for your help !
Would it be okay to simply create a unique table to store the articles returned by the API when users are querying it ?
Yes. If the articles have unique keys (doi?) you could use INSERT...ON CONFLICT DO NOTHING to handle the (presumably very rare) case that an article is requested by two people nearly simultaneously.
Shall I rather store the articles returned by the API and associate each of them to the user that requested it (the Article model will contain a foreign key mapping to a User model)?
Do you want to? Is there a reason to? Do you care who requested each article? It sounds like you anticipating storing only the first person to request each article, and not every request?
Or shall I give each user a table (data isolation would be good but that sounds very inefficient)?
Right, you would be hitting the API a lot more often (assuming some large fraction of articles are requested more than once) and storing a lot of duplicates. It might not even solve the problem, if one person hits "submit" twice in a row, or has multiple tabs open, or writes a bot to hit your service in parallel.
I am looking to have additional data added onto my models after the JSON data is returned from the service. The service I talk to returns information as a code, but I want to also include a more readable name to display to users. This would be done almost everywhere the model is used.
Example:
Fetch from the service
{schedule: {code:'MONTHLY'}}
Have access to
{schedule: {code:'MONTHLY', name: 'Monthly'}}
This would be for things which have a map of code to name, where name only ever lives on the front end, and code is what is persisted. I see there is a concept of custom transforms, would this be the way to go?
I also plan to keep a mapping of all possible codes/names in another file, to iterate over or compare to the model's attributes. For instance I would want to present users with a choice of schedules to choose from, MONTHLY, QUARTERLY, or ANNUALLY.
You should create a Computed Property on a model. You can call it: "name" or "displayName". It should depend on "code" attribute on model. Inside computed property, you should access a service. Service should have a method to map code -> name. A method you call from the model on service should return you a name. A code-name map should be separated from the model.
Whenever you want to access displayName Computed Property from model use model.displayName.
I'm currently in a situation where I need to create a Repository class which would contain multiple financial statistic queries. The queries are not exactly tied up with one Entity but rather with multiple Entities and will select specific data from the database, based on various some conditions.
Having said that, I'm looking for a way to create a Repository class (i.e. StatisticsRepository) which is not associated with an Entity at all, so I could store the queries there. Simply creating that repository doesn't seem to be working. I'm guessing I probably need to create a service of some kind that loads this repo class? Is this correct, and if so is there an example I'm missing in the Symfony/Doctrine docs?
You can just create a class like StatisticsService/StatisticsFinder (naming convention is for you).
That service should have an entity manager injected, so define it in your config.
Create a query builder inside that service, then simply get and return results.
How should I structure my Actors in Akka persistent (Eventsourcing/CQRS) ?
Hierarchical
Parallel
I have these domain objects in my ecommerce application
User - User can create account
Store - User can create store
Product - User can add products to it's store
Cart - A User can add any product from other User's stores into the Cart.
So my question is how should I structure my Actors ? What are advantages and disadvantages of choosing one over the other specially in relation to an Ecommerce domain model ?
I think your question is more about the boundaries of your aggregates.
In any case, there should be NO hierarchical structure between aggregates. Aggregates should be independent from each other. No parent child relationship.
According to your description. There is a User Aggregate that can create stores and add products to it.
Store could be an apart aggregate that is initiated by the User aggregate. Note that the fact that an user can create a Store doesn't mean that they should have a parent/child relationship. It's more about access control. A Store is created by a user and only this user have right to add products to it.
However, Product seems to be a entity inside the Store aggregate.
Your fourth example, "Cart - A User can add any product from other User's stores into the Cart", reveals something totally different. You have two kind of users. Users that create and manage stores and consumers of a given store. They are not the same and they should be modeled differently.
Try to model the domain of your business without trying to reuse objects just because they are similar.
My django application need to collect user data(name age country etc) based on his email domain( 'gmail' as in xyz#gmail.com).I wist to create a new table every time i encounter a new email domain.
Can this be done in django ?
This is a bad idea. Your tables would all have the same structure. All of your data should be stored in a single table, with a domain column to keep the data separate. Why would you want a different table for each domain? Whatever reason you have, there's a better way to do it.
This idea goes against everything in the design of the relational database, and the Django ORM on top of it.