Skip to content

Commit 0d05028

Browse files
replace byIdentifier with byId
1 parent 8703ad3 commit 0d05028

File tree

1 file changed

+18
-18
lines changed
  • src/pages/[platform]/build-a-backend/data/working-with-files

1 file changed

+18
-18
lines changed

src/pages/[platform]/build-a-backend/data/working-with-files/index.mdx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ To retrieve the file associated with a record, first query the record, then use
264264
<InlineFilter filters={["swift"]}>
265265
```swift title="ContentView"
266266
// Get the song record
267-
let song = try await Amplify.API.query(request: .get(Song.self, byIdentifier: currentSong.id)).get()
267+
let song = try await Amplify.API.query(request: .get(Song.self, byId: currentSong.id)).get()
268268

269269
// Download the art cover
270270
let imageData = try await Amplify.Storage.downloadData(path: .fromString((song?.coverArtPath)!)).value
@@ -316,7 +316,7 @@ The following example removes the file association from the record, but does not
316316
<InlineFilter filters={["swift"]}>
317317
```swift title="ContentView"
318318
// Get the song record
319-
var song = try await Amplify.API.query(request: .get(Song.self, byIdentifier: currentSong.id)).get()
319+
var song = try await Amplify.API.query(request: .get(Song.self, byId: currentSong.id)).get()
320320

321321
// If the record has no associated file, we can return early.
322322
guard song?.coverArtPath != nil else {
@@ -368,7 +368,7 @@ The following example removes the file from the record, then deletes the file fr
368368
<InlineFilter filters={["swift"]}>
369369
```swift title="ContentView"
370370
// Get the song record
371-
var song = try await Amplify.API.query(request: .get(Song.self, byIdentifier: currentSong.id)).get()
371+
var song = try await Amplify.API.query(request: .get(Song.self, byId: currentSong.id)).get()
372372

373373
// If the record has no associated file, we can return early.
374374
guard let coverArtPath = song?.coverArtPath else {
@@ -424,7 +424,7 @@ await remove({ path: song.coverArtPath });
424424
<InlineFilter filters={["swift"]}>
425425
```swift title="ContentView"
426426
// Get the song record
427-
let song = try await Amplify.API.mutate(request: .get(Song.self, byIdentifier: currentSong.id)).get()
427+
let song = try await Amplify.API.mutate(request: .get(Song.self, byId: currentSong.id)).get()
428428

429429
// Delete the record from the API
430430
let deleteResult = try await Amplify.API.mutate(request: .delete(song!))
@@ -603,7 +603,7 @@ _ = try await Amplify.Storage.uploadData(path: .fromString(path),
603603
data: imageData).value
604604

605605
// Query existing record to retrieve currently associated files:
606-
var album = try await Amplify.API.query(request: .get(PhotoAlbum.self, byIdentifier: currentAlbum.id)).get()
606+
var album = try await Amplify.API.query(request: .get(PhotoAlbum.self, byId: currentAlbum.id)).get()
607607

608608
guard var imagePaths = album?.imagePaths else {
609609
print("Album does not contain images")
@@ -777,7 +777,7 @@ To retrieve the files associated with a record, first query the record, then use
777777
<InlineFilter filters={["swift"]}>
778778
```swift title="ContentView"
779779
// Query the record to get the file paths:
780-
let album = try await Amplify.API.query(request: .get(PhotoAlbum.self, byIdentifier: currentAlbum.id)).get()
780+
let album = try await Amplify.API.query(request: .get(PhotoAlbum.self, byId: currentAlbum.id)).get()
781781

782782
// If the record has no associated files, we can return early.
783783
guard let imagePathsOptional = album?.imagePaths else {
@@ -855,7 +855,7 @@ The workflow for deleting and removing files associated with API records is the
855855
]}>
856856
```swift title="ContentView"
857857
// Get the API record:
858-
var album = try await Amplify.API.query(request: .get(PhotoAlbum.self, byIdentifier: currentAlbum.id)).get()
858+
var album = try await Amplify.API.query(request: .get(PhotoAlbum.self, byId: currentAlbum.id)).get()
859859

860860
// If the record has no associated file, we can return early.
861861
guard let imagePaths = album?.imagePaths, !imagePaths.isEmpty else {
@@ -906,7 +906,7 @@ const updatedPhotoAlbum = await client.models.PhotoAlbum.update({
906906
]}>
907907
```swift title="ContentView"
908908
// Get the API record:
909-
var album = try await Amplify.API.query(request: .get(PhotoAlbum.self, byIdentifier: currentAlbum.id)).get()
909+
var album = try await Amplify.API.query(request: .get(PhotoAlbum.self, byId: currentAlbum.id)).get()
910910

911911
// If the record has no associated files, we can return early.
912912
guard let imagePathsOptional = album?.imagePaths else {
@@ -980,7 +980,7 @@ await Promise.all(
980980
<InlineFilter>
981981
```swift title="ContentView"
982982
// Get the album record
983-
var album = try await Amplify.API.query(request: .get(PhotoAlbum.self, byIdentifier: currentAlbum.id)).get()
983+
var album = try await Amplify.API.query(request: .get(PhotoAlbum.self, byId: currentAlbum.id)).get()
984984

985985
// If the record has no associated file, we can return early.
986986
guard let imagePathsOptional = album?.imagePaths else {
@@ -1325,7 +1325,7 @@ class SongViewModel: ObservableObject {
13251325
await setCurrentImage(nil)
13261326

13271327
// Get the song record
1328-
let result = try await Amplify.API.query(request: .get(Song.self, byIdentifier: currentSong.id))
1328+
let result = try await Amplify.API.query(request: .get(Song.self, byId: currentSong.id))
13291329
guard case .success(let queriedSong) = result else {
13301330
print("Failed with error: ", result)
13311331
return
@@ -1364,7 +1364,7 @@ class SongViewModel: ObservableObject {
13641364
}
13651365

13661366
// Get the song record
1367-
let result = try await Amplify.API.mutate(request: .get(Song.self, byIdentifier: currentSong.id))
1367+
let result = try await Amplify.API.mutate(request: .get(Song.self, byId: currentSong.id))
13681368
guard case .success(let queriedSong) = result else {
13691369
print("Failed with error: ", result)
13701370
return
@@ -1403,7 +1403,7 @@ class SongViewModel: ObservableObject {
14031403
}
14041404

14051405
// Get the song record
1406-
let result = try await Amplify.API.query(request: .get(Song.self, byIdentifier: currentSong.id))
1406+
let result = try await Amplify.API.query(request: .get(Song.self, byId: currentSong.id))
14071407
guard case .success(let queriedSong) = result else {
14081408
print("Failed with error: ", result)
14091409
return
@@ -1447,7 +1447,7 @@ class SongViewModel: ObservableObject {
14471447
}
14481448

14491449
// Get the song record
1450-
let result = try await Amplify.API.mutate(request: .get(Song.self, byIdentifier: currentSong.id))
1450+
let result = try await Amplify.API.mutate(request: .get(Song.self, byId: currentSong.id))
14511451
guard case .success(let queriedSong) = result else {
14521452
print("Failed with error: ", result)
14531453
return
@@ -1760,7 +1760,7 @@ class PhotoAlbumViewModel: ObservableObject {
17601760
options: .init(accessLevel: .private)).value
17611761

17621762
// Get the latest album
1763-
let result = try await Amplify.API.query(request: .get(PhotoAlbum.self, byIdentifier: currentAlbum.id))
1763+
let result = try await Amplify.API.query(request: .get(PhotoAlbum.self, byId: currentAlbum.id))
17641764
guard case .success(let queriedAlbum) = result else {
17651765
print("Failed with error: ", result)
17661766
return
@@ -1851,7 +1851,7 @@ class PhotoAlbumViewModel: ObservableObject {
18511851
await setCurrentImages([])
18521852

18531853
// Get the song record
1854-
let result = try await Amplify.API.query(request: .get(PhotoAlbum.self, byIdentifier: currentAlbum.id))
1854+
let result = try await Amplify.API.query(request: .get(PhotoAlbum.self, byId: currentAlbum.id))
18551855
guard case .success(let queriedAlbum) = result else {
18561856
print("Failed with error: ", result)
18571857
return
@@ -1910,7 +1910,7 @@ class PhotoAlbumViewModel: ObservableObject {
19101910
}
19111911

19121912
// Get the album record
1913-
let result = try await Amplify.API.mutate(request: .get(PhotoAlbum.self, byIdentifier: currentAlbum.id))
1913+
let result = try await Amplify.API.mutate(request: .get(PhotoAlbum.self, byId: currentAlbum.id))
19141914
guard case .success(let queriedAlbum) = result else {
19151915
print("Failed with error: ", result)
19161916
return
@@ -1951,7 +1951,7 @@ class PhotoAlbumViewModel: ObservableObject {
19511951
}
19521952

19531953
// Get the album record
1954-
let result = try await Amplify.API.query(request: .get(PhotoAlbum.self, byIdentifier: currentAlbum.id))
1954+
let result = try await Amplify.API.query(request: .get(PhotoAlbum.self, byId: currentAlbum.id))
19551955
guard case .success(let queriedAlbum) = result else {
19561956
print("Failed with error: ", result)
19571957
return
@@ -2014,7 +2014,7 @@ class PhotoAlbumViewModel: ObservableObject {
20142014
}
20152015

20162016
// Get the album record
2017-
let result = try await Amplify.API.query(request: .get(PhotoAlbum.self, byIdentifier: currentAlbum.id))
2017+
let result = try await Amplify.API.query(request: .get(PhotoAlbum.self, byId: currentAlbum.id))
20182018
guard case .success(let queriedAlbum) = result else {
20192019
print("Failed with error: ", result)
20202020
return

0 commit comments

Comments
 (0)