10_bookstore_json_out

command
v0.0.0-...-baf0b24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2020 License: MIT Imports: 2 Imported by: 0

README

From Postgres

[{"Isbn":"978-1505255607","Title":"The Time Machine","Author":"H. G. Wells","Price":5.99},{"Isbn":"978-1503261960","Title":"Wind Sand \u0026 Stars","Author":"Antoine","Price":14.99},{"Isbn":"978-1503261961","Title":"West With The Night","Author":"Beryl Markham","Price":14.99}]

notice \u0026

That is valid JSON encoding. That is the unicode escape. & doesn't have to be encoded, but Go does this so we can just let it be. JSON encoders / decoders know how to deal with it.

Setup

  1. Login as the Admin of your mongo db as in User & Permission Commands article

  2. Create the user

use bookstore
db.createUser(
  {
    user: "bond",
    pwd: "password",
    roles: [ { role: "readWrite", db: "bookstore" } ]
  }
)
exit
  1. Login as the user
mongo -u "bond" -p "password" --authenticationDatabase "bookstore"
use bookstore
db.books.insert([{"Isbn":"978-1505255607","Title":"The Time Machine","Author":"H. G. Wells","Price":5.99},{"Isbn":"978-1503261960","Title":"Wind Sand \u0026 Stars","Author":"Antoine","Price":14.99},{"Isbn":"978-1503261961","Title":"West With The Night","Author":"Beryl Markham","Price":14.99}])

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL