Advertisement
Guest User

Untitled

a guest
Dec 11th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. MongoDB lab
  2.  
  3. Prerequisites:
  4.  
  5. Open http://try.mongodb.org/
  6.  
  7. 1. Store a trade record with party, counterparty, product, base
  8.  
  9. Enter:
  10.  
  11. var transaction = {party: 'BOFA', counterparty: 'JPMC', product: 'XYZ', base: '3.05'};
  12.  
  13. Response:
  14.  
  15. >
  16. {
  17. "party" : "BOFA",
  18. "counterparty" : "JPMC",
  19. "product" : "XYZ",
  20. "base" : "3.05"
  21. }
  22.  
  23. Enter:
  24.  
  25. db.my.save({recordtype: 'transaction', party: 'BOFA', counterparty: 'JPMC', product: 'XYZ', base: '3.05'});
  26.  
  27. Response:
  28. “ok”
  29.  
  30. Enter:
  31. db.my.find()
  32.  
  33. Response:
  34.  
  35. { "recordtype" : "transaction", "_id" : { "$oid" : "513deb60cc93742c1602da9d" }, "product" : "XYZ", "party" : "BOFA", "counterparty" : "JPMC", "base" : "3.05" },
  36.  
  37.  
  38.  
  39. 2. Store another trade with more fields: clearing house, currency
  40.  
  41. Enter:
  42.  
  43. db.my.save({recordtype: 'transaction', party: 'BOFA', counterparty: 'JPMC', product: 'XYZ', base: '3.05', clearing_house: 'LCH', currency: "GBP"});
  44.  
  45. Response:
  46. “ok”
  47.  
  48. db.my.find()
  49.  
  50. { "clearing_house" : "LCH", "recordtype" : "transaction", "_id" : { "$oid" : "513dec30cc93742c1602da9f" }, "product" : "XYZ", "party" : "BOFA", "currency" : "GBP", "counterparty" : "JPMC", "base" : "3.05" }
  51.  
  52. 3. Store a third record, which is the first slightly modified and with the changed order of fields
  53.  
  54. Enter:
  55.  
  56. db.my.save({party: 'BOFA', counterparty: 'JPMC', product: 'XYZ', base: '3.10', recordtype: 'transaction'});
  57.  
  58. Response:
  59.  
  60. “ok”
  61.  
  62. Enter:
  63.  
  64. db.my.find()
  65.  
  66. Response:
  67.  
  68. { "recordtype" : "transaction", "_id" : { "$oid" : "513ded4fcc93742c1602dab1" }, "product" : "XYZ", "party" : "BOFA", "counterparty" : "JPMC", "base" : "3.10" }
  69.  
  70. 4. Open MongoDB in a hex editor.
  71.  
  72. (For example, in vi do this:
  73. :%!xxd
  74.  
  75. show how the data is stored as it is entered
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement