Add support for Polymorphism #10

Closed
a-musing-moose opened this Issue May 1, 2011 · 1 comment

Comments

Projects
None yet
2 participants
@a-musing-moose
Owner

a-musing-moose commented May 1, 2011

We need to add support for polymorphism - That is to say storing multiple types within a single collection. e.g. The classic example of Shape, and then multiple classes which extend it for different types of shape.

Class hierarchy:

Shape

  • Circle
  • Square
  • etc...

@ghost ghost assigned a-musing-moose May 1, 2011

@chrsm

This comment has been minimized.

Show comment Hide comment
@chrsm

chrsm Jul 12, 2012

Contributor

I know this is your project, and I'm just commenting on it, but this is for anyone who comes through here and is looking for similar information:

/**
 * $collection
 *
 * The name of the collection that this will be stored in
 * 
 * @var string
 */
protected $collection = 'Shape';

This is what I am doing for certain types of things that are getting stored; I simply have a property in the document named 'type' which further distinguishes what the object is (for when it's queried out of the DB).

There's also the collection() method..which I just now noticed. -.-

Contributor

chrsm commented Jul 12, 2012

I know this is your project, and I'm just commenting on it, but this is for anyone who comes through here and is looking for similar information:

/**
 * $collection
 *
 * The name of the collection that this will be stored in
 * 
 * @var string
 */
protected $collection = 'Shape';

This is what I am doing for certain types of things that are getting stored; I simply have a property in the document named 'type' which further distinguishes what the object is (for when it's queried out of the DB).

There's also the collection() method..which I just now noticed. -.-

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