Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MongoDB lab
- Prerequisites:
- Open http://try.mongodb.org/
- 1. Store a trade record with party, counterparty, product, base
- Enter:
- var transaction = {party: 'BOFA', counterparty: 'JPMC', product: 'XYZ', base: '3.05'};
- Response:
- >
- {
- "party" : "BOFA",
- "counterparty" : "JPMC",
- "product" : "XYZ",
- "base" : "3.05"
- }
- Enter:
- db.my.save({recordtype: 'transaction', party: 'BOFA', counterparty: 'JPMC', product: 'XYZ', base: '3.05'});
- Response:
- “ok”
- Enter:
- db.my.find()
- Response:
- { "recordtype" : "transaction", "_id" : { "$oid" : "513deb60cc93742c1602da9d" }, "product" : "XYZ", "party" : "BOFA", "counterparty" : "JPMC", "base" : "3.05" },
- 2. Store another trade with more fields: clearing house, currency
- Enter:
- db.my.save({recordtype: 'transaction', party: 'BOFA', counterparty: 'JPMC', product: 'XYZ', base: '3.05', clearing_house: 'LCH', currency: "GBP"});
- Response:
- “ok”
- db.my.find()
- { "clearing_house" : "LCH", "recordtype" : "transaction", "_id" : { "$oid" : "513dec30cc93742c1602da9f" }, "product" : "XYZ", "party" : "BOFA", "currency" : "GBP", "counterparty" : "JPMC", "base" : "3.05" }
- 3. Store a third record, which is the first slightly modified and with the changed order of fields
- Enter:
- db.my.save({party: 'BOFA', counterparty: 'JPMC', product: 'XYZ', base: '3.10', recordtype: 'transaction'});
- Response:
- “ok”
- Enter:
- db.my.find()
- Response:
- { "recordtype" : "transaction", "_id" : { "$oid" : "513ded4fcc93742c1602dab1" }, "product" : "XYZ", "party" : "BOFA", "counterparty" : "JPMC", "base" : "3.10" }
- 4. Open MongoDB in a hex editor.
- (For example, in vi do this:
- :%!xxd
- show how the data is stored as it is entered
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement