Almazbeck Djumabaev
Almazbeck Djumabaev

Reputation: 11

beforeCreate function sailsjs

Before storing data to database I must modify string . Here's my code

beforeCreate:function(value ) 
{      
    value.text = value.text.replace(/(\t|\n)/g, '');   
} 

How to add callback to this function? I know that there must participate callback.

Upvotes: 1

Views: 458

Answers (1)

brittonjb
brittonjb

Reputation: 502

I believe this should do it:

beforeCreate: function(values, callback) {      
   values.text = values.text.replace(/(\t|\n)/g, '');
   return callback();   
} 

You can refer to the docs for more examples.

Upvotes: 2

Related Questions