func CascadeSave(collection *Collection, doc Document) error {
	// Find out which properties to cascade
	if conv, ok := doc.(CascadingDocument); ok {
		toCascade := conv.GetCascade(collection)
		for _, conf := range toCascade {

			if len(conf.ReferenceQuery) == 0 {
				conf.ReferenceQuery = []*ReferenceField{&ReferenceField{"_id", doc.GetId()}}
			}
			_, err := cascadeSaveWithConfig(conf, doc)
			if err != nil {
				return err
			}
			if conf.Nest {
				results := conf.Collection.Find(conf.Query)

				for results.Next(conf.Instance) {
					err = CascadeSave(conf.Collection, conf.Instance)
					if err != nil {
						return err
					}
				}

			}
		}
	}
	return nil
}
func CascadeSave(collection *Collection, doc Document) error {
	// Find out which properties to cascade
	if conv, ok := doc.(CascadingDocument); ok {
		toCascade := conv.GetCascade(collection)
		for _, conf := range toCascade {

			if len(conf.ReferenceQuery) == 0 {
				conf.ReferenceQuery = []*ReferenceField{&ReferenceField{"_id", doc.GetId()}}
			}
			_, err := cascadeSaveWithConfig(conf, doc)
			if err != nil {
				return err
			}
			if conf.Nest {
				results := conf.Collection.Find(conf.Query)

				for results.Next(conf.Instance) {
					err = CascadeSave(conf.Collection, conf.Instance)
					if err != nil {
						return err
					}
				}

			}
		}
	}
	return nil
}
// Cascades a document's properties to related documents, after it has been prepared
// for db insertion (encrypted, etc)