在Sequelize> = 1.7中,我们可以使用promises
你能解释一下我如何从这个代码中获得每个用户的值:
var User = sequelize.define("user", {
username: Sequelize.STRING
})
User
.sync({ force: true })
.then(function() { return User.create({ username: 'John' }) })
.then(function(john) { return User.create({ username: 'Jane' }) })
.then(function(jane) { return User.create({ username: 'Pete' }) })
.then(function(pete) {
console.log("we just created 3 users :)")
console.log("this is pete:")
console.log(pete.values)
// what i want:
console.log("this is jane:")
console.log(jane.values)
console.log("this is john:")
console.log(john.values)
})
Run Code Online (Sandbox Code Playgroud)
UPD
所有值都需要与其他模型设置关联.其实我需要一些像这样的代码:
User.hasMany(Group)
Group.hasMany(User)
User
.sync({ force: true })
.then(function() { return User.create({ …Run Code Online (Sandbox Code Playgroud) 我正在尝试以编程方式使用ruby填写pdf.pdf包含允许输入文本的字段:
我已经使用在过去成功pdftk通过pdf_form创业板,但是它没有找到在这个特殊的PDF格式的字段:
$ pry
[1] pry(main)> require 'pdf_forms'
=> true
[2] pry(main)> pdftk = PdfForms.new('/usr/local/bin/pdftk')
=> #<PdfForms::PdftkWrapper:0x007fece7af6d98 @options={}, @pdftk="/usr/local/bin/pdftk">
[3] pry(main)> pdftk.get_field_names('designation.pdf')
=> []
Run Code Online (Sandbox Code Playgroud)
如何使用ruby填写pdf?
我尝试过使用aws-sdk和knox,我得到状态代码301试图上传图像.我得到状态码301和消息 - '您尝试访问的存储桶必须使用指定的端点进行寻址.请将以后的所有请求发送到此端点.这适用于PHP.
AWS.config.loadFromPath(__dirname + '/config/config.json');
fs.readFile(source, function (err, data) {
var s3 = new AWS.S3();
s3.client.createBucket({Bucket: 'mystuff'}, function() {
var d = {
Bucket: 'mystuff',
Key: 'img/test.jpg',
Body: data,
ACL: 'public-read'
};
s3.client.putObject(d, function(err, res) {
if (err) {
console.log("Error uploading data: ", err);
callback(err);
} else {
console.log("Successfully uploaded data to myBucket/myKey");
callback(res);
}
});
});
});
Run Code Online (Sandbox Code Playgroud) 给定以下 ruby 文件 foo.rb:
# this is a module comment
module A
# this is a constant comment
B = 'hi'
# this is a class comment
class C
# this is a method comment
# @param [String] name Who to say hi to
# @return [String]
def self.hi(name)
"#{B}, #{name}"
end
end
end
Run Code Online (Sandbox Code Playgroud)
{A::C => 'this is a class comment'}如何以编程方式获取与特定对象(例如, )相关的注释{B => 'this is a constant comment'}?
我期望YARD.parse(File.read('/path/to/foo.rb'))或YARD::Parser::SourceParser.parse(File.read('/path/to/foo.rb'))做某事,但它们返回空数组。YARD::Parser::Ruby::RubyParser.parse(File.read('/path/to/foo.rb'))返回一个YARD::Parser::Ruby::RipperParser看似 …
ruby ×2
amazon-s3 ×1
bluebird ×1
javascript ×1
node.js ×1
pdf ×1
pdftk ×1
promise ×1
sequelize.js ×1
yard ×1