MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / update

Function update

chirpstack/src/storage/gateway.rs:243–266  ·  view source on GitHub ↗
(gw: Gateway)

Source from the content-addressed store, hash-verified

241}
242
243pub async fn update(gw: Gateway) -> Result<Gateway, Error> {
244 gw.validate()?;
245
246 let gw: Gateway = diesel::update(gateway::dsl::gateway.find(&gw.gateway_id))
247 .set((
248 gateway::updated_at.eq(Utc::now()),
249 gateway::name.eq(&gw.name),
250 gateway::description.eq(&gw.description),
251 gateway::latitude.eq(&gw.latitude),
252 gateway::longitude.eq(&gw.longitude),
253 gateway::altitude.eq(&gw.altitude),
254 gateway::stats_interval_secs.eq(&gw.stats_interval_secs),
255 gateway::tags.eq(&gw.tags),
256 gateway::downlink_priority.eq(&gw.downlink_priority),
257 ))
258 .get_result(&mut get_async_db_conn().await?)
259 .await
260 .map_err(|e| Error::from_diesel(e, gw.gateway_id.to_string()))?;
261 info!(
262 gateway_id = %gw.gateway_id,
263 "Gateway updated"
264 );
265 Ok(gw)
266}
267
268pub async fn partial_update(gateway_id: EUI64, gw: &GatewayChangeset) -> Result<Gateway, Error> {
269 let gw = diesel::update(gateway::dsl::gateway.find(&gateway_id))

Callers 3

partial_updateFunction · 0.70
update_relay_gatewayFunction · 0.70
test_gatewayFunction · 0.70

Calls 4

setMethod · 0.80
to_stringMethod · 0.80
get_async_db_connFunction · 0.70
validateMethod · 0.45

Tested by 1

test_gatewayFunction · 0.56