Should I store a very long array in back-end or front-end?
In my angular application, I have a very long array and would like to put it some where I could access very easily from my front-end don't slow down my application, there are multiple options and I don't which one is the best. Should I store it in:
my API
app.get('models', (req, res) =>{var models = ['m1', 'm2', 'm3', ..., 'mn'];
res.send(models);
});
In API DB:
app.get('models', (req, res) =>{
Models.find({}, (dara, err){
res.send(models);
})
});
in my front-end:
// models.ts
in a variable in my component
any comment will be appreciate.
node.js angular mongodb typescript
add a comment |
In my angular application, I have a very long array and would like to put it some where I could access very easily from my front-end don't slow down my application, there are multiple options and I don't which one is the best. Should I store it in:
my API
app.get('models', (req, res) =>{var models = ['m1', 'm2', 'm3', ..., 'mn'];
res.send(models);
});
In API DB:
app.get('models', (req, res) =>{
Models.find({}, (dara, err){
res.send(models);
})
});
in my front-end:
// models.ts
in a variable in my component
any comment will be appreciate.
node.js angular mongodb typescript
local storage did u give it a try, you can retrieve throughout your app'n hassle free.
– super cool
Nov 23 '18 at 5:35
2
I think you need to be clearer about what you mean by "store" and probably avoid using terms like "best practice". Just try and show us what you actually need to do instead.
– Neil Lunn
Nov 23 '18 at 5:41
@NeilLunn Since it is very big array, I think it could have a bad influence on performance
– dmx
Nov 23 '18 at 5:49
You're being very abstract, which is not good for a question here. I'm prompting you to add detail to your question and explain what you think you need to do in a way that people can clearly see it and give you a clear answer. So editing your question with more descriptive detail is advisable.
– Neil Lunn
Nov 23 '18 at 5:52
This really depends on how it is used. Try several ways and see what works best for you. Consider initial load time of the client, caching on the client, ...
– Henry
Nov 23 '18 at 6:08
add a comment |
In my angular application, I have a very long array and would like to put it some where I could access very easily from my front-end don't slow down my application, there are multiple options and I don't which one is the best. Should I store it in:
my API
app.get('models', (req, res) =>{var models = ['m1', 'm2', 'm3', ..., 'mn'];
res.send(models);
});
In API DB:
app.get('models', (req, res) =>{
Models.find({}, (dara, err){
res.send(models);
})
});
in my front-end:
// models.ts
in a variable in my component
any comment will be appreciate.
node.js angular mongodb typescript
In my angular application, I have a very long array and would like to put it some where I could access very easily from my front-end don't slow down my application, there are multiple options and I don't which one is the best. Should I store it in:
my API
app.get('models', (req, res) =>{var models = ['m1', 'm2', 'm3', ..., 'mn'];
res.send(models);
});
In API DB:
app.get('models', (req, res) =>{
Models.find({}, (dara, err){
res.send(models);
})
});
in my front-end:
// models.ts
in a variable in my component
any comment will be appreciate.
node.js angular mongodb typescript
node.js angular mongodb typescript
edited Nov 23 '18 at 6:03
dmx
asked Nov 23 '18 at 5:25
dmxdmx
641725
641725
local storage did u give it a try, you can retrieve throughout your app'n hassle free.
– super cool
Nov 23 '18 at 5:35
2
I think you need to be clearer about what you mean by "store" and probably avoid using terms like "best practice". Just try and show us what you actually need to do instead.
– Neil Lunn
Nov 23 '18 at 5:41
@NeilLunn Since it is very big array, I think it could have a bad influence on performance
– dmx
Nov 23 '18 at 5:49
You're being very abstract, which is not good for a question here. I'm prompting you to add detail to your question and explain what you think you need to do in a way that people can clearly see it and give you a clear answer. So editing your question with more descriptive detail is advisable.
– Neil Lunn
Nov 23 '18 at 5:52
This really depends on how it is used. Try several ways and see what works best for you. Consider initial load time of the client, caching on the client, ...
– Henry
Nov 23 '18 at 6:08
add a comment |
local storage did u give it a try, you can retrieve throughout your app'n hassle free.
– super cool
Nov 23 '18 at 5:35
2
I think you need to be clearer about what you mean by "store" and probably avoid using terms like "best practice". Just try and show us what you actually need to do instead.
– Neil Lunn
Nov 23 '18 at 5:41
@NeilLunn Since it is very big array, I think it could have a bad influence on performance
– dmx
Nov 23 '18 at 5:49
You're being very abstract, which is not good for a question here. I'm prompting you to add detail to your question and explain what you think you need to do in a way that people can clearly see it and give you a clear answer. So editing your question with more descriptive detail is advisable.
– Neil Lunn
Nov 23 '18 at 5:52
This really depends on how it is used. Try several ways and see what works best for you. Consider initial load time of the client, caching on the client, ...
– Henry
Nov 23 '18 at 6:08
local storage did u give it a try, you can retrieve throughout your app'n hassle free.
– super cool
Nov 23 '18 at 5:35
local storage did u give it a try, you can retrieve throughout your app'n hassle free.
– super cool
Nov 23 '18 at 5:35
2
2
I think you need to be clearer about what you mean by "store" and probably avoid using terms like "best practice". Just try and show us what you actually need to do instead.
– Neil Lunn
Nov 23 '18 at 5:41
I think you need to be clearer about what you mean by "store" and probably avoid using terms like "best practice". Just try and show us what you actually need to do instead.
– Neil Lunn
Nov 23 '18 at 5:41
@NeilLunn Since it is very big array, I think it could have a bad influence on performance
– dmx
Nov 23 '18 at 5:49
@NeilLunn Since it is very big array, I think it could have a bad influence on performance
– dmx
Nov 23 '18 at 5:49
You're being very abstract, which is not good for a question here. I'm prompting you to add detail to your question and explain what you think you need to do in a way that people can clearly see it and give you a clear answer. So editing your question with more descriptive detail is advisable.
– Neil Lunn
Nov 23 '18 at 5:52
You're being very abstract, which is not good for a question here. I'm prompting you to add detail to your question and explain what you think you need to do in a way that people can clearly see it and give you a clear answer. So editing your question with more descriptive detail is advisable.
– Neil Lunn
Nov 23 '18 at 5:52
This really depends on how it is used. Try several ways and see what works best for you. Consider initial load time of the client, caching on the client, ...
– Henry
Nov 23 '18 at 6:08
This really depends on how it is used. Try several ways and see what works best for you. Consider initial load time of the client, caching on the client, ...
– Henry
Nov 23 '18 at 6:08
add a comment |
1 Answer
1
active
oldest
votes
The answer depends on what you want to do, so:
In the Frontend
Is never a good idea try to have data on your frontend, this implicates that the user will request for a full list of data that will only use or read a few.
If you still consider that you wanna do it there: You can have always in a constant, then you can consume that using local storage(be careful with the space limitation 10MB), global variables or just a file to import
Note: Using suspense or any lazy loading you will be able to avoid sending this data at the same time that everything else.
In the Backend
Yes, is the best place to have information that you need to request, there you can use a DB to store and a GET to request it is the common and best approach.
Note: Avoid send all the list in one request in you can, try indexing or use pagination, for most of the cases you don't need have such big arrays on FE.
But at the end, is more a decision based on what you want to build that only one good answer.
Hope this helps you!
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441040%2fshould-i-store-a-very-long-array-in-back-end-or-front-end%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The answer depends on what you want to do, so:
In the Frontend
Is never a good idea try to have data on your frontend, this implicates that the user will request for a full list of data that will only use or read a few.
If you still consider that you wanna do it there: You can have always in a constant, then you can consume that using local storage(be careful with the space limitation 10MB), global variables or just a file to import
Note: Using suspense or any lazy loading you will be able to avoid sending this data at the same time that everything else.
In the Backend
Yes, is the best place to have information that you need to request, there you can use a DB to store and a GET to request it is the common and best approach.
Note: Avoid send all the list in one request in you can, try indexing or use pagination, for most of the cases you don't need have such big arrays on FE.
But at the end, is more a decision based on what you want to build that only one good answer.
Hope this helps you!
add a comment |
The answer depends on what you want to do, so:
In the Frontend
Is never a good idea try to have data on your frontend, this implicates that the user will request for a full list of data that will only use or read a few.
If you still consider that you wanna do it there: You can have always in a constant, then you can consume that using local storage(be careful with the space limitation 10MB), global variables or just a file to import
Note: Using suspense or any lazy loading you will be able to avoid sending this data at the same time that everything else.
In the Backend
Yes, is the best place to have information that you need to request, there you can use a DB to store and a GET to request it is the common and best approach.
Note: Avoid send all the list in one request in you can, try indexing or use pagination, for most of the cases you don't need have such big arrays on FE.
But at the end, is more a decision based on what you want to build that only one good answer.
Hope this helps you!
add a comment |
The answer depends on what you want to do, so:
In the Frontend
Is never a good idea try to have data on your frontend, this implicates that the user will request for a full list of data that will only use or read a few.
If you still consider that you wanna do it there: You can have always in a constant, then you can consume that using local storage(be careful with the space limitation 10MB), global variables or just a file to import
Note: Using suspense or any lazy loading you will be able to avoid sending this data at the same time that everything else.
In the Backend
Yes, is the best place to have information that you need to request, there you can use a DB to store and a GET to request it is the common and best approach.
Note: Avoid send all the list in one request in you can, try indexing or use pagination, for most of the cases you don't need have such big arrays on FE.
But at the end, is more a decision based on what you want to build that only one good answer.
Hope this helps you!
The answer depends on what you want to do, so:
In the Frontend
Is never a good idea try to have data on your frontend, this implicates that the user will request for a full list of data that will only use or read a few.
If you still consider that you wanna do it there: You can have always in a constant, then you can consume that using local storage(be careful with the space limitation 10MB), global variables or just a file to import
Note: Using suspense or any lazy loading you will be able to avoid sending this data at the same time that everything else.
In the Backend
Yes, is the best place to have information that you need to request, there you can use a DB to store and a GET to request it is the common and best approach.
Note: Avoid send all the list in one request in you can, try indexing or use pagination, for most of the cases you don't need have such big arrays on FE.
But at the end, is more a decision based on what you want to build that only one good answer.
Hope this helps you!
answered Nov 23 '18 at 6:36
Miguel AngelMiguel Angel
474212
474212
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441040%2fshould-i-store-a-very-long-array-in-back-end-or-front-end%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
local storage did u give it a try, you can retrieve throughout your app'n hassle free.
– super cool
Nov 23 '18 at 5:35
2
I think you need to be clearer about what you mean by "store" and probably avoid using terms like "best practice". Just try and show us what you actually need to do instead.
– Neil Lunn
Nov 23 '18 at 5:41
@NeilLunn Since it is very big array, I think it could have a bad influence on performance
– dmx
Nov 23 '18 at 5:49
You're being very abstract, which is not good for a question here. I'm prompting you to add detail to your question and explain what you think you need to do in a way that people can clearly see it and give you a clear answer. So editing your question with more descriptive detail is advisable.
– Neil Lunn
Nov 23 '18 at 5:52
This really depends on how it is used. Try several ways and see what works best for you. Consider initial load time of the client, caching on the client, ...
– Henry
Nov 23 '18 at 6:08