blog.depold.com |
Web programming to the rescue! A blog about Node.JS, JavaScript and Ruby on Rails! |
glynnbird asked: In order to may Sequelize scalable, I wondered whether it would be a good idead to (optionally) provide two sets of MySQL connection credentials; one for read-only operations, and the other for write operations. The Sequelize can send its SELECT statements to the read-only connection and write operations to the read-write connection. This would allow applications with lots of read operations to scale out using MySQL slaves. What do you think?
good idea :) can you open a ticket on github?
stumblmumbl asked: Hi, in Sequelize JS is it possible to refer to a model twice from another model? For example, if in Project I would like one User reference for the Manager, and another for the Lead Developer. How would I do that in Sequelize?
Hi!
Yes this is possible. You have to add the ‘as’-option to your definition. Take a look at this part of the documentation.
Hope that helps
cjfoote asked: Hi, I'm using the Dawanda jQuery RSS code to aggregate an RSS feed to a news website I'm building, and it runs great so long as I only run a single instance of the plugin. However, I'd like to run it twice, once for the story headline and once for the body content. This doesn't seem to work, since each new version of the code I link to overwrites the original version. Any suggestions? I'd appreciate it :)
Hmm that should actually work … Mhh can you please open an issue on github and add a link to page where this problem can be replayed? Thanks a lot :)
Sequelize v1.3.0 was just released and comes with some funky new features and some minor refactorings, which you should know about. Most important things are: Migrations, validations, cross-database support and new event-listener notation.
Read more
stumblmumbl asked: Greetings! Not sure if this is the best place to ask, but I've got a sequelize question for you: is there a way to define something like a custom type, or perhaps add a constraint? For example, say I would like to add a column called "gender". I could make it a string, but then anything could be entered. I could make a "genders" table and do "Person.hasOne(Gender)", which is a common DB method, but kind of klunky since you would then have a "genderid" column. Is there a better way? Thanks!
Hi!
For now it is not possible to add a special data type. But you could use the boolean datatype for the ‘sex’-attribute and add a gender method which evaluates the attribute and returns ‘male’ or ‘female’ as value. Take a look at http://sequelizejs.com/?active=expanding-models#expanding-models and http://sequelizejs.com/?active=data-types#data-types for further information. What do you think?
With best regards,
Sascha
ckoewing asked: First of all a big approval to your project 'Sequelize', it's awesome!!! Of course i would like to use it, but i'm a newbie in js, node and express. :( So, did you know an example where Sequelize is used together with JMVC (JavascriptMVC framework)? I'm searching for a javascript-based client- and server-side application architecture. I hope you can help me. :)
Hey there, you can use express with sequelize. Express is actually only seperating the view from the controller. To get the model layer, I recommend to create a folder called “models”. Afterwards you can add model files (e.g. person.js) and import it in the controller.
Does this help?
multiracial asked: Hello! I'm taking a look at your jquery-rss and I was wondering if I could get a little help in altering the {date} so that it just shows Month, day, and year. Thanks for any help you can provide!
Hey there. The correct way is to take the already available date and transform it the way you need it:
$(“#rss-feeds”).rss(“http://feeds.feedburner.com/dawanda”, {
limit: 15,
template: ‘{date2}: {title}’,
tokens: {
date2: function(entry, tokens){
var date = new Date(Date.parse(tokens.date))
return [date.getFullYear(), date.getMonth() + 1, date.getDay()].join(“-“)
}
}
})
Let me know if that helps :)
Hey Mac gamers, about an year ago I wrote an article about, how to get Theme Hospital work on Mac OS X. Because that post is very old and things have changed, here is an updated how-to.
Read more
And that’s it. JSConf.EU 2011 is done. Great conf! Here is my summary about the second day’s talks.
The first talk of the day was by Tomasz Janczuk about High density server side java script. The microsoft speaker was talking about possibilities to lower hosting costs for lightweight applications (actual node apps). He assumed costs of 5€ per month as current normal hosting costs. Way too much, according to him. Tomasz splitted the currently process based hosting approach into threads. Doing so, each application won’t run in a single process but in process’ threads. Because the resulting price reduction was not enough, he was going on. An explaination followed, which outlined the hierarchy of V8 apps with it’s V8::Isolates and it’s V8::Contexts. Basically each application has an isolate and in that one specific context. However, Tomasz was splitting the Isolate into multiple contexts, running each an application. This was finally resulting in a demonstration of 1000 chat servers running all in a single thread’s V8::Isolate. If I remember correctly the final price was about 0,30€ a month.
Tomasz was using the tool Denser, which spawned the processes and started a web gui with some information about hardware usage and network traffic. You can find it here.
Read more