Code Monkey home page Code Monkey logo

coat-persistent's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lartet dams

coat-persistent's Issues

delete should change the state of the object

The following code is buggy:

$obj->save
$obj->delete
$obj->save

Once deleted, the row corresponding to the object is dropped from the database, but C::P does not change the internal state of the object. Hence, the next save call will fail, because it thinks the entry exists in the DB and will try t run an UPDATE query on a non-existent field.

The state should be changed when delete is called (CP_ENTRY_NEW), then a new save call will trigger a INSERT query.

Support for dynamic finders

Currently, only one kind of per-attribute finder is supported: find_by_ATTR, they are statically created in the namespace of the class.

ActiveRecord chose to use an AUTOLOAD system to create them on the fly, this allow any finder to be possible, like

Class->find_by_attr1_and_attr2(1, 2);
Class->find_by_attr1_or_attr2(1, 2);

We could do the same as ActiveRecord does and once a finder is called, register it in the namespace.

Support for virtual models

When more than one model share somt common attrbutes and filters, it's convenient to factor them in a common ancestor, like the following:

package WithDate;
use Coat::Persistent;

has_p 'created_at' => (
     isa => 'Class::Date',
     store_as => 'DateTime',
);

before save => sub {
    my ($self) = @_;
    $self->created_at(time) unless $self->created_at;
};

And then, others model can 'extends' WithDate. That works, but something is a bit dirty: WithDate does not map a real table in the database, so it should be marked as a "virtual" model.

My idea is that a virtual model in Coat::Persistent is actually a Role.

packahe WithDate;
use Coat::Persistent::Virtual;

....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.