Skip to content
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

Embedded relations don't invoke operation hooks #480

Closed
brunocascio opened this issue Mar 4, 2015 · 8 comments
Closed

Embedded relations don't invoke operation hooks #480

brunocascio opened this issue Mar 4, 2015 · 8 comments
Assignees

Comments

@brunocascio
Copy link

My code:

{
  "name": "Step",
  "base": "PersistedModel",
  "strict":true,
  "properties": {
    "pos": {
      "type": "number",
      "required": true
    },
    "text": {
      "type": "string",
      "required": true
    }
  },
  "validations": [],
  "relations": {
    "image": {
      "type": "embedsOne",
      "model": "Image",
      "options": {
        "persistent":true
      }
    }
  },
  "acls": [],
  "methods": []
}
{
  "name": "Image",
  "base": "PersistedModel",
  "properties": {
    "name": {
      "type": "string",
      "required": true
    }
  },
  "validations": [],
  "relations": {},
  "acls": [],
  "methods": []
}
Image.observe('access', function imageProcessing(ctx, next) {
        console.log('access') 
}

Image.observe('before save', function imageProcessing(ctx, next) {
        console.log('before save image') 
}

Not show logs in console.

@bajtos
Copy link
Member

bajtos commented Mar 5, 2015

Thank you for reporting the issue. For a better context, can you reproduce the same problem when using the "old" model hooks like "beforeCreate"?

@bajtos bajtos changed the title "hooks" is not calling when use "embedsOne" or "embedsMany" relation Embedded relations don't invoke operation hooks Mar 5, 2015
@brunocascio
Copy link
Author

I changed all data model. I using mysql right now. Sorry :/

@iamlogiq
Copy link

@bajtos
Any Idea when this issue will be fixed? I"m having the same problem. When I try to create a new model that has an embedded relation it is not calling the "create" method set in the connector.
Please help!

@bajtos
Copy link
Member

bajtos commented Jun 12, 2015

There is a partial solution proposed in #516. Could you please try it out and let us know how it works for you?

@zelphir
Copy link

zelphir commented Jun 17, 2015

@bajtos What should be this solution?

@ShaharHD
Copy link

I can confirm that on my mongodb based setup, 'before save' event is not firing on the embedded model when I call from the API Explorer POST /Model/{id}/embedded

unless - I define it as persistent in the embedded model options

@Allan1
Copy link

Allan1 commented May 7, 2017

+1

@stale stale bot added the stale label Aug 23, 2017
@stale stale bot closed this as completed Sep 6, 2017
@shenghu
Copy link
Contributor

shenghu commented Dec 1, 2017

@fabien , I'm trying to understand persistent. In documentation, it says persistent - denote if the embedded items should be persisted, default to false. But when I set it to be 'false', I can see the embedded document is saved to mongo within the parent document. What does persistent control?

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

No branches or pull requests