- Dao - A ColdFusion library for easy and db agnostic CRUD interaction and Linq style query building.
- Norm (Not ORM) - A dynamic Object Mapping layer built on top of DAO that provides oData support and ORM style object interactions (load, save, relate entities, etc...).
Dao/Norm is a duo of libraries that provide a simple yet full featured interface to perform script based queries as well as adds extended functionality such as ORM (with easy and dynamic relationships), oData (Consume/Produce), LINQ style queries and more. Basically it is the data interaction ColdFusion/Railo/Lucee should have come with out of the box.
In short, the goal of this library is to allow one to interact with the database in a DB platform agnostic way, while making it super easy.
Currently this library has been actively used and tested on Lucee 4x, CF11+
Clone this repo and copy the "database" folder (/database)
into your project (or into the folder you place your components)
box install dao
dao = new database.dao();
dao.update("sometable",form);
function getUsers(){
// normally injected or in applicaiton scope
dao = new database.dao();
return dao.read(
sql = "
SELECT fname as firstName, lname as lastName
FROM Users
",
returnType = "array"
);
}
writeOutput( getUsers() );
Output:
[
{"firstName":"Jill","lastName":"Smith"},
{"firstName":"Joe","lastName":"Blow"},
{"firstName":"John","lastName":"Cash"}
]
dao.from( "eventLog" )
.where( "eventDate", "<", now() )
.andWhere( "eventDate", ">=", dateAdd( 'd', -1, now() ) )
.run();
User = new database.Norm("user");
User.loadByFirstName("joe");
User.setStatus("online");
User.save();
Documentation and Examples: https://github.com/abramadams/dao/wiki
Chat: The CFML team Slack - Ask questions in the #cfml-general channel and mention @abram.
Pull requests welcome! See installation instructions for setup and testing.
Copyright (c) 2007-2018 Abram Adams. All rights reserved.
The use and distribution terms for this software are covered by the Apache Software License 2.0 (http://www.apache.org/licenses/LICENSE-2.0) which can also be found in the file LICENSE at the root of this distribution and in individual licensed files. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.