New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added daoFactory.findOrInitialize(params, defaults) #960

Merged
merged 3 commits into from Oct 14, 2013

Conversation

2 participants
@durango
Member

durango commented Oct 3, 2013

This functionality acts pretty much the same way as
daoFactory.findOrCreate except you don't actually create the record,
Sequelize would only .build() it. beforeValidate/afterValidate hooks
will still run in the same manner as findOrCreate().

This functionality was inspired by:
http://guides.rubyonrails.org/active_record_querying.html#find-or-initialize-by

Added daoFactory.findOrInitialize(params, defaults)
This functionality acts pretty much the same way as
daoFactory.findOrCreate except you don't actually create the record,
Sequelize would only .build() it. beforeValidate/afterValidate hooks
will still run in the same manner as findOrCreate().

This functionality was inspired by:
http://guides.rubyonrails.org/active_record_querying.html#find-or-initialize-by
@sdepold

This comment has been minimized.

Member

sdepold commented Oct 3, 2013

why not findOrBuild ?

@durango

This comment has been minimized.

Member

durango commented Oct 3, 2013

@sdepold I can add an alias, but really.. it was because those coming from ActiveRecord will be more familiar with this terminology (build = initialized.. initialized is actually used in other ORMs as well such as SQLAlchemy amongst others). Build is also used though, don't get me wrong, but I just went with what has already been established within the ORM ecosystem.

@sdepold

This comment has been minimized.

sdepold commented on 2470c1d Oct 3, 2013

thanks

@sdepold sdepold merged commit 56c3530 into sequelize:master Oct 14, 2013

1 check passed

default The Travis CI build passed
Details

@durango durango deleted the durango:findOrInitialize branch Oct 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment