API Design Notes Part 3

24 Feb 2014

Data Persistence Notes

Database:

Collections:

Functions:

Data Bootstrap:

  1. Start MongoD: "mongod --dbpath 'data path'"
  2. If Database does not exist create. "use api"
  3. If Collections do not exist create. "db.persons.insert("sample_person.json");db.movies.insert("sample_movie.json");"
  4. Test Collections exists. "show collections"
  5. Mongo Dump : "mongodump --db api --out 'data path/dump_name'"
  6. Mongo Restore : "mongorestore 'dump path'"

Sample Collection Members

movie object

{
  "description": "An exclusive golf course has to deal with a brash new member and a destructive dancing gopher.",
  "datePublished": "2013-03-28T21:51:08.406Z",
  "name": "Caddyshack",
  "about": "An exclusive golf course has to deal with a brash new member and a destructive dancing gopher.",
  "genre": "comedy",
  "version": 1,
  "timeRequired": "PT180M",
  "contentRating": "r",
  "director": "1a2356778",
  "actors": "1a56258, 2abckegs, 78799abc"
}

movie meta

{
  "description": "description of movie",
  "datePublished": "date movie was published"
  "name": "title of movie",
  "about": "short description of movie",
  "genre": "genre of movie",
  "version": "version of this release",
  "timeRequired": "time required to view this movie also known as duration",
  "contentRating": "movie rating",
  "director": "director of this movie",
  "actors": "actors in this film"
}

person object

{
  "additionalName": "mather",
  "birthDate": "2013-03-28T00:00:00.000Z",
  "familyName": "barnard",
  "givenName": "bryan",
  "gender": "male",
  "deathDate": ""
}

person meta

{
  "additionalName": "alternate or middle name",
  "birthDate": "date of birth",
  "familyName": "family name, last name in US",
  "givenName": "name, first name in US",
  "gender": "gender",
  "deathDate": "date of death"
}

Reference: