Search - process natively or make an API call? (Android, Node.JS, MongoDB Backend)

I am creating a mobile ecommerce app (android app) that displays a list of events to users. These events may / will change daily.

The landing page of the app will make the following API call to the Node.JS server to receive today's events (<500 I assume):

/get/events

      

Now I want to implement a search function in my mobile app. There are two ways to get around this (I think):

  • Refer to android app search using local android app database (this will help me implement Autocomplete functionality)

  • When the user enters a query string, make an API call to the server to get a list of relevant results. This API call will find MongoDB results (text search functions) and return them in JSON format to Android Applicatio app, e.g .:

/get/search?q='Festival'

Also, I will also have to implement filters (like music, drama, comedy, etc.), so I have the same question for this as well (refer to Android or API call).

Which of the above is preferred? It would be very helpful to know this. Thank!

+3


source to share


2 answers


This is a pretty broad question, but it looks like you have these requirements:

  • node.js is a backend tool that will allow you to easily connect to your existing mongodb database.
  • search / query records via REST API
  • returns results in JSON format


The sails.js framework does all of this out of the box. If you define your model definitions for your database, you don't need to write any custom logic to enable searching and filtering your data through the REST API.

Getting started with sails.js is easy, even if you don't know node.js. Look SailsCast video to see if you fit sails.js. If you have any questions, sails.js has live community support at Gitter: https://gitter.im/balderdashy/sails

+2


source


This is ultimately the decision you will have to make depending on the time you have to meet and the server load requirements.

Leaving the search function on the server is often the easiest solution since you only need to deal with searching the database in one place. Also, depending on the application, you just need to send a small subset of the available data, not all. However, if you plan to receive a large number of requests frequently, this can deplete your server resources.



Since you only sync data once a day, it might be worth considering your local database approach. This will take more effort to implement as you have to worry about fetching new data, populating the local database, and implementing search on each device. If your search functionality changes, users will need to update their app for the changes to affect them. Also, if you have a large number of users, you may need a staggering daily search to prevent too many server requests at once.

0


source







All Articles