Skip to content

Commit 1827deb

Browse files
DOC-4228 example and formatting corrections
1 parent 9d2802c commit 1827deb

File tree

1 file changed

+74
-2
lines changed

1 file changed

+74
-2
lines changed

doctests/json_tutorial_test.go

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,78 @@ func ExampleClient_setbikes() {
475475
// REMOVE_END
476476

477477
// STEP_START set_bikes
478+
var inventory_json = map[string]interface{}{
479+
"inventory": map[string]interface{}{
480+
"mountain_bikes": []interface{}{
481+
map[string]interface{}{
482+
"id": "bike:1",
483+
"model": "Phoebe",
484+
"description": "This is a mid-travel trail slayer that is a fantastic " +
485+
"daily driver or one bike quiver. The Shimano Claris 8-speed groupset " +
486+
"gives plenty of gear range to tackle hills and there\u2019s room for " +
487+
"mudguards and a rack too. This is the bike for the rider who wants " +
488+
"trail manners with low fuss ownership.",
489+
"price": 1920,
490+
"specs": map[string]interface{}{"material": "carbon", "weight": 13.1},
491+
"colors": []interface{}{"black", "silver"},
492+
},
493+
map[string]interface{}{
494+
"id": "bike:2",
495+
"model": "Quaoar",
496+
"description": "Redesigned for the 2020 model year, this bike " +
497+
"impressed our testers and is the best all-around trail bike we've " +
498+
"ever tested. The Shimano gear system effectively does away with an " +
499+
"external cassette, so is super low maintenance in terms of wear " +
500+
"and tear. All in all it's an impressive package for the price, " +
501+
"making it very competitive.",
502+
"price": 2072,
503+
"specs": map[string]interface{}{"material": "aluminium", "weight": 7.9},
504+
"colors": []interface{}{"black", "white"},
505+
},
506+
map[string]interface{}{
507+
"id": "bike:3",
508+
"model": "Weywot",
509+
"description": "This bike gives kids aged six years and older " +
510+
"a durable and uberlight mountain bike for their first experience " +
511+
"on tracks and easy cruising through forests and fields. A set of " +
512+
"powerful Shimano hydraulic disc brakes provide ample stopping " +
513+
"ability. If you're after a budget option, this is one of the best " +
514+
"bikes you could get.",
515+
"price": 3264,
516+
"specs": map[string]interface{}{"material": "alloy", "weight": 13.8},
517+
},
518+
},
519+
"commuter_bikes": []interface{}{
520+
map[string]interface{}{
521+
"id": "bike:4",
522+
"model": "Salacia",
523+
"description": "This bike is a great option for anyone who just " +
524+
"wants a bike to get about on With a slick-shifting Claris gears " +
525+
"from Shimano\u2019s, this is a bike which doesn\u2019t break the " +
526+
"bank and delivers craved performance. It\u2019s for the rider " +
527+
"who wants both efficiency and capability.",
528+
"price": 1475,
529+
"specs": map[string]interface{}{"material": "aluminium", "weight": 16.6},
530+
"colors": []interface{}{"black", "silver"},
531+
},
532+
map[string]interface{}{
533+
"id": "bike:5",
534+
"model": "Mimas",
535+
"description": "A real joy to ride, this bike got very high " +
536+
"scores in last years Bike of the year report. The carefully " +
537+
"crafted 50-34 tooth chainset and 11-32 tooth cassette give an " +
538+
"easy-on-the-legs bottom gear for climbing, and the high-quality " +
539+
"Vittoria Zaffiro tires give balance and grip.It includes " +
540+
"a low-step frame , our memory foam seat, bump-resistant shocks and " +
541+
"conveniently placed thumb throttle. Put it all together and you " +
542+
"get a bike that helps redefine what can be done for this price.",
543+
"price": 3941,
544+
"specs": map[string]interface{}{"material": "alloy", "weight": 11.6},
545+
},
546+
},
547+
},
548+
}
549+
478550
res1, err := rdb.JSONSet(ctx, "bikes:inventory", "$", inventory_json).Result()
479551

480552
if err != nil {
@@ -850,7 +922,7 @@ func ExampleClient_filter3() {
850922
panic(err)
851923
}
852924

853-
fmt.Println(res10) // >>>
925+
fmt.Println(res10) // >>> ["Salacia","Mimas","Quaoar","Weywot"]
854926
// STEP_END
855927

856928
// Output:
@@ -1048,7 +1120,7 @@ func ExampleClient_updatefilters2() {
10481120
panic(err)
10491121
}
10501122

1051-
// STEP_START update_filters_2
1123+
// STEP_START update_filters2
10521124
res20, err := rdb.JSONArrAppend(ctx,
10531125
"bikes:inventory",
10541126
"$.inventory.*[?(@.price<2000)].colors",

0 commit comments

Comments
 (0)