vlog-parser
v1.0.0
Published
``` #!javascript var parse = require('vlog-parser')
Downloads
2
Readme
Usage
#!javascript
var parse = require('vlog-parser')
let raw_user_data = {}
let raw_video_data = {}
let user = parse.user(data)
let video = parse.video(data)
// Here, both `user` and `video`
// return FALSE as no info is passed.
// We can see errors passed back by using
// a callback:
parse.user(data, (err, user) => {
// Here, `err` will be something like:
// [ 'Missing key \'username\'.',
// 'Missing key \'avatar\'.',
// 'Missing key \'verified\'.' ]
})
We can also parse Mongo ObjectID
s:
#!javascript
let user_id = '56012e9e10191f3f155f0f7d'
let user_obj_id = parser.ObjectId(user_id)
// Here, user_obj_id is now a valid ObjectID.
// If the ID is not deemed valid, the parser
// will return NULL.