let s = new Subscriber({name:'Sn'});
let p = new Post({title:'Pt',subscriber:s });
let u = new User({name:'Un', post: p});
s.save();
p.save();
u.save();
[
{
"_id": "58a81fd04396bb59443950e0",
"name": "Un",
"post": {
"_id": "58a81fd04396bb59443950df",
"title": "Pt",
"subscriber": {
"_id": "58a81fd04396bb59443950de",
"name": "Sn",
"__v": 0
},
"__v": 0
},
"__v": 0
}
]
const request = require('request-json');
const Promise = require('bluebird');
let client = request.createClient(SITE_URL);
client.post = Promise.promisify(client.post);
Promise.coroutine(function* () {
let data1 = createDataStruct(61, 1, 1);
let result1 = yield client.post(SITE_PATH, data);
let data2 = createDataStruct(61, 1, 1);
let result2 = yield client.post(SITE_PATH, data);
console.log(result1, result2);
})();
var iconv = require('iconv-lite');
var fs = require('fs');
fs.writeFileSync('win1251.txt', iconv.encode('Привет!', 'win1251'));
redis.setnx(token, 'lock', function (err, acquired) {
if (err) { /*...*/ }
if (acquired) {
// ... some code
redis.del(token, function (err) { /*...*/ }); // unlock
}
});
writable.write()
возвращает false в случае если данные которые вы передали попадут в буфер на отправку, а не будут отправлены сразу.{ email: { type: 'email', required: true, unique: true } }
var connection = require('./lib/connection');
var login = require('./lib/login');
module.exports = function (io) {
io.on('connection', function (socket) {
connection(socket, io);
login(socket, io);
});
};
mongoose.connect('mongodb://localhost/myapp');
.