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

Function upsert_vendor

chirpstack/src/storage/device_profile.rs:546–565  ·  view source on GitHub ↗
(v: Vendor)

Source from the content-addressed store, hash-verified

544}
545
546pub async fn upsert_vendor(v: Vendor) -> Result<Vendor, Error> {
547 let v: Vendor = diesel::insert_into(device_profile_vendor::table)
548 .values(&v)
549 .on_conflict(device_profile_vendor::id)
550 .do_update()
551 .set((
552 device_profile_vendor::updated_at.eq(Utc::now()),
553 device_profile_vendor::name.eq(&v.name),
554 device_profile_vendor::vendor_id.eq(&v.vendor_id),
555 device_profile_vendor::ouis.eq(&v.ouis),
556 device_profile_vendor::metadata.eq(&v.metadata),
557 ))
558 .get_result(&mut get_async_db_conn().await?)
559 .await
560 .map_err(|e| error::Error::from_diesel(e, v.id.to_string()))?;
561
562 info!(id = %v.id, "Device-profile vendor upserted");
563
564 Ok(v)
565}
566
567pub async fn get_vendor_count() -> Result<i64, Error> {
568 Ok(device_profile_vendor::table

Callers 4

test_device_profileFunction · 0.85
runFunction · 0.85
handle_vendorFunction · 0.85
test_device_profileFunction · 0.85

Calls 3

setMethod · 0.80
to_stringMethod · 0.80
get_async_db_connFunction · 0.70

Tested by 2

test_device_profileFunction · 0.68
test_device_profileFunction · 0.68