Advertisement
Guest User

Untitled

a guest
May 17th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Test user name and ID
  2. var userName = 'test',
  3.     userID   = 'BYWBSgfnPL6lpMmS'
  4.  
  5.  
  6. /* Function to populate db with test documents
  7.  *
  8.  */
  9. async function populate(hh) {
  10.   // wait for the database connection
  11.   await hh.connect()
  12.  
  13.   let hubuser =
  14.     await hh.createHubUser(userName, 'password')
  15.  
  16.   let user =
  17.     await hh.createUser(userName, {
  18.       _id: userID,
  19.       hubuser: hubuser._id // ссылка на документ hubuser
  20.     })
  21.  
  22.   let u = await models.User.findOne({username: userName})
  23.  
  24.   console.log(user.toJSON())
  25.   console.log(u.toJSON())
  26. }
  27.  
  28.  
  29. // Странные дела, вот это не так, как мы с тобой предпологали!!!
  30.  
  31. { _id: 'BYWBSgfnPL6lpMmS',
  32.   username: 'test',
  33.   hubuser: 'E5yYmj4Pyr3N7E51' }
  34. { _id: 'BYWBSgfnPL6lpMmS',
  35.   username: 'test',
  36.   hubuser:
  37.    { _id: 'E5yYmj4Pyr3N7E51',
  38.      username: 'test',
  39.      password: 'password',
  40.      token: { value: undefined, expires: undefined } } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement