Direct insert into DB vs using API

vrish8 months ago

Hi,
I have to do a few bulk additions such as linking multiple devices to single geofence. I might have to do this in a loop for a few geofences.

There are 2 ways of doing it.

  1. Call the API multiple times for each combination of deviceId and geofenceId (this is obviously slower than the bulk insert)
  2. Run a simple bulk insert into tc_device_geofence

Which is better? If I use #2 (bulk insert into the DB), is there any caching that is affected? Will the geofence trigger work normally? Or do I have to trigger any kind of cache reset?

Thank you

Anton Tananaev8 months ago

Using API is definitely recommended option.

But if you want to do it one off, you can just restart the service after changing database directly.

vrish8 months ago

Thanks Anton.

A follow up question: Is there a way to bulk add permissions using the API? For example, instead of passing a single object {"deviceId":1234, "geofenceId":3} can I pass an array like this [{"deviceId":1234, "geofenceId":3},{"deviceId":1235, "geofenceId":3}] ?

I looked in the code and it seems to only be taking an object instead of an array .. so I wanted to confirm.

Anton Tananaev8 months ago

Where in the code did you look?