Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Omereshone Kelvin Oghenerhoro
@DominusKelvin
Like so:
Model.find({
  tags: { in: ['foo', 'bar'] }
});
contains is mostly for matching a part of a string. Let me know if this helps
@eitanbronschtein did you by any chance turned of blueprint routes?
Rob Guinness
@robguinness_gitlab

Hi, I'm trying to create my first helper, and I'm getting an ImplementationError:

(node:71095) UnhandledPromiseRejectionWarning: ImplementationError: Failed to call this function ("isInDataSubscription") synchronously,
because it is not actually synchronous.  Instead, its implementation is asynchronous--
which is inconsistent with its declared interface (`sync: true`).
If you are the maintainer of "isInDataSubscription", then you can change its
implementation so that it's actually synchronous.  Otherwise, please file a bug report
with the maintainer, or fork your own copy and fix that.
 [?] See https://sailsjs.com/support for help.
    at /home/rob/teqmine/teqmine-backend/api/controllers/ExploreResultsController.js:63:32
    at Array.map (<anonymous>)
    at /home/rob/teqmine/teqmine-backend/api/controllers/ExploreResultsController.js:62:43
    at /home/rob/teqmine/teqmine-backend/api/services/elasticsearchPatentService.js:24:18
    at process._tickCallback (internal/process/next_tick.js:68:7)

I have defined my helper to be synchronous, as it doesn't make any asynchronous calls. Here is the definition:

const isInDefaultSubscription = (patent) => {
  ...
  return false
}

module.exports = {
  friendlyName: "Check whether the data is included in the user's subscription",
  description: "Check whether the data is included in the user's subscription",
  inputs: {

    subscription: {
      type: 'string',
      example: 'global',
      description: 'The name of the data subscription',
      allowNull: true,
    },
    patent: {
      type: 'ref',
      description: 'The patent being checked',
      required: true
    },

  },
  exits: {
    success: {
      description: 'All done.',
    },
  },
  sync: true,
  fn: function(inputs) {
    switch (inputs.subscription) {
      case 'global':
        return true;
      case 'default':
        if (isInDefaultSubscription(inputs.patent)) {
          return true
        } else {
          return false
        }
      default:
        if (isInDefaultSubscription(inputs.patent)) {
          return true
        } else {
          return false
        }
    }
  }
}

I have left out some implementation details from isInDefaultSubscription, but rest assured, it is a normal synchronous function.

Am I missing something, or why is sails complaining that my implementation of the helper is asynchronous?

vrajasekhar1
@vrajasekhar1
@robguinness_gitlab Error indicates “isInDataSubscription" is not synchronous. You may want to recheck that once.
Rob Guinness
@robguinness_gitlab

It really is synchronous. :-) I even tried replacing it with:

function isInDefaultSubscription(patent) {
  return true
}

I get the same result.

I even tried defining the helper function like this as a test:
  fn: function(inputs) {
    switch (inputs.subscription) {
      case 'global':
        return true;
      case 'default':
        if (true) {
          return true
        } else {
          return false
        }
      default:
        if (true) {
          return true
        } else {
          return false
        }
    }
  }
Rob Guinness
@robguinness_gitlab
In fact, even this gives the same error:
  fn: function(inputs) {
    return true
  }
sandeepkumarnetrovert
@sandeepkumarnetrovert

RELOAD ORM HOOK IN A CUSTOM HOOK.

Hi, I want to dynamically add a new data store in the sails application without lifting it again.
I know it is possible to give data store configuration dynamically before lifting the app.
(Ref : balderdashy/sails#3518 )
What I'm looking for is in inline with the above issue except I want to reload ORM layer if there is any new data store.

I saw that we can reload orm hook with sails.hooks.orm.reload();
https://github.com/balderdashy/sails-hook-orm but it is mentioned as an private API and not supposed to be used in custom hook.

Any thoughts, suggestions are welcome .
Thanks

Jason
@jlincoln
eslint is reporting 'Model' is not defined in controller/actions. Should models be manually added to .eslintignore?
Jason
@jlincoln
Oops! I see the models section in the .eslintrc file. I will add the models there.
Gil Mendes
@gil0mendes

Hey guys,

There is any way to create a dynamic attribute at the model level as was possible to do in the past? Something like this:

shortName () {
        const parts = this.name.split(' ')
        if (parts.length < 2) { return parts[0]; }

        return `${parts[0]} ${parts[parts.length - 1]}`
}
Gil Mendes
@gil0mendes
I think that was called user methods in the past.
Gil Mendes
@gil0mendes
Btw, how can I use the unique validator? When I set it on the attribute it says that The propertyuniqueisn't a recognized property..
Hardik Sukhadiya
@hardiksukhadiya
Hello Guys,
How to ignore UTC conversion of datetime field values in get query
I am using latest version of sails js : 1.4.0
can any one help me on that ?
2 replies
Shashika Pradeep
@jashashika_twitter

Hi All,
I'm new to Sails Js and moved from Laravel to node js project recently. I'm struggling to save an extra field with 'addToCollection' in waterline. How can I do it.

1st Table : Teams
2nd Table: Agents

intermediate table TeamAgent
columns are
team_id, agent_id, roles

await Team.addToCollection(1, 'agents')
.members([1,2]);

how can I add data to the roles column in this query? Please update me.

1 reply
Saffet Emin Reisoğlu
@sereisoglu
Hi everyone. Has anyone used agendash with sails before?
Omereshone Kelvin Oghenerhoro
@DominusKelvin
@robguinness_gitlab are you calling a Promise by any chance?.
Majed Badawi
@MajedBadawi

Hello, I am using dynamodb with sails.
I have an attribute in my model as following:

books: { type: 'json', columnName: 'books', columnType: 'array', defaultsTo: [] },
However, when creating a record this attribute is not added. I tried setting it in the create params as [] and new Array() but didn't work.

1 reply
Muhammad Inaam Munir
@Muhammadinaam
Is it possible to do like this: sails.log.error("Error occurred", error); error is an object
2 replies
HighVoltage
@HighVol63940075_twitter
Does anybody know how to use npm packages live e.g. bootstrap-vue?
3 replies
i can't figure out how to use those custom components.
or is that not supported and i have to make my own component for everything?
Jessica Bibiano
@JessBibiano
Hi guys, I'm having a problem with sails to connect to my database
Jessica Bibiano
@JessBibiano
I'm getting an error "error: A hook (orm) failed to load!"
7 replies
AlpayGencSoftware
@AlpayGencSoftware
Hi Everyone
3 replies
I will be installing with sails for a new project but this installing has failed :(
I use mac os height sierra
AlpayGencSoftware
@AlpayGencSoftware
Which node js version I should be using?
Abdullah Yousuf
@thecodeparadox

Hi, I'm trying to connect to aws document db using sails-mongo adaptar with below URL format:
mongodb://USERNAME:PASS123!@xxx.docdb.amazonaws.com:27017/?sslCA=/path/to/rds-combined-ca-bundle.pem&replicaSet=rs0&ssl=false but getting below error:

error: Could not tear down the ORM hook.  Error details: Error: Consistency violation: Attempting to tear down a datastore (`default`) which is not currently registered with this adapter.  This is usually due to a race condition in userland code (e.g. attempting to tear down the same ORM instance more than once), or it could be due to a bug in this adapter.

How can I successfully connect? Please need some help. Thanks.

7 replies
Jason
@jlincoln
Any ideas why this.req.me of API controller would not be getting set when sails is installed behind nginx reverse proxy (AWS Elastic Beanstalk single node)?
9 replies
Jason
@jlincoln
It's the login pager controller created via sails new that isn't finding a this.req.me. Works fine on dev.
Made By Seed
@madebyseed
Hello everyone, do you know how to connect Mongo Atlas to SailsJS?
1 reply
jinalvirani
@jinalvirani

Hello, do you know how we can get the mongoClient in SailsJS?
I want change stream in SailsJS and implemented this code
const pipeline = [
{
$project: { documentKey: false }
}
];
try {
var db = sails.getDatastore().manager;
var collection = db.collection('user');
console.log(collection);
const changeStream = collection.watch(pipeline);
changeStream.on("change", function(change) {
console.log(change);
});
} catch (err) {
res.serverError(err);
}

It throws an error: collection.watch is not a function

Petro Kok
@PetroKok
Hello, what is the compatible version of sails-postgresql for sailsjs "^1.4.0"? Looks like fetch, meta, usingConnection methods don't work.
4 replies
Jaki Chavez
@angjaki_gitlab
Hello, this error occurred just right now in our SailsJS server. Is anyone here familiar with it?
05:09:34 app-0 A socket is being allowed to connect, but the session could not be loaded. Will create an empty, one-time session to use for the life of the socket connection. Details:
05:09:34 app-0 Error: Session could not be loaded
05:09:34 app-0 at _createError (/tmp/node_modules/sails/lib/hooks/session/index.js:31:19)
05:09:34 app-0 at Immediate.<anonymous> (/tmp/node_modules/sails/lib/hooks/session/index.js:34:11)
05:09:34 app-0 at runCallback (timers.js:653:20)
05:09:34 app-0 at tryOnImmediate (timers.js:622:5)
05:09:34 app-0 at processImmediate [as _immediateCallback] (timers.js:594:5).
Martin Barilík
@martinbarilik
Hi, i am trying to set up socket.io-redis host for different envs (prod, dev and qa), but i am unablle to find any useful info. Where should i put those urls specific to an env ?
2 replies
Mike DeVita
@mikedevita
hello, does anyone have a working example w/ passport that I can review?
Andy Gnz
@Gonzov
Hey guys, so I added my Stripe keys. My question how do I charge my customer who added their card? I was trying to find in docs but I couldn't.
Abhishek Gupta
@tikur1
Hi, when someone calls http://localhost:3000/api then the base URL hits(http://localost:1337). is it anyway how can I achieve this
MaheshSreenath.V.M
@MaheshSreenath_twitter
Any one can help with angular 10 and sails socket connection?
any link or documentation would be really helpful i was able to connect to sails using sails.io.js but broadcasting messages is not working
Noitidart
@Noitidart

has anyone used env var to set password for sockets? doing the following gives me error -

docker run -p 1337:1337 --name effendi ghcr.io/noitidart/effendi:latest -e sails_sockets__pass='myFakePassword'
docker run -p 1337:1337 --name effendi ghcr.io/noitidart/effendi:latest -e sails_sockets__pass="myFakePassword"
docker run -p 1337:1337 --name effendi ghcr.io/noitidart/effendi:latest -e sails_sockets__pass=myFakePassword

ReferenceError: myFakePassword is not defined

Lukas Bahr
@lukasbahr
Hey guys, I need some help concerning sending mails. Is sendgrid required to send mails or can we use the mail address from the webhost? #noidea
Noitidart
@Noitidart
Anyone seen this error when trying to use a managed hosted database? I deployed using same techniques before and didnt get this error. But now I am:
Troubleshooting tips:

 -> Is your Postgresql configuration correct?  Maybe your `poolSize` configuration is set too high? e.g. If your Postgresql database only supports 20 concurrent connections, you should make sure you have your `poolSize` set as something < 20 (see http://stackoverflow.com/a/27387928/486547). The default `poolSize` is 10. To override default settings, specify the desired properties on the relevant Postgresql "connection" config object where the host/port/database/etc. are configured. If you're using Sails, this is generally located in `config/datastores.js`, or wherever your environment-specific database configuration is set.

 -> Maybe your `poolSize` configuration is set too high? e.g. If your Postgresql database only supports 20 concurrent connections, you should make sure you have your `poolSize` set as something < 20 (see http://stackoverflow.com/a/27387928/486547). The default `poolSize` is 10.

 -> Do you have multiple Sails instances sharing the same Postgresql database? Each Sails instance may use up to the configured `poolSize` # of connections. Assuming all of the Sails instances are just copies of one another (a reasonable best practice) we can calculate the actual # of Postgresql connections used (C) by multiplying the configured `poolSize` (P) by the number of Sails instances (N). If the actual number of connections (C) exceeds the total # of **AVAILABLE** connections to your Postgresql database (V), then you have problems.  If this applies to you, try reducing your `poolSize` configuration. A reasonable `poolSize` setting would be V/N.

 -> Are you using an SSL-enabled Postgresql host like Heroku? Make sure to set `ssl` to `true` (see http://stackoverflow.com/a/22177218/486547)


error: Sending 500 ("Server Error") response: 
 AdapterError: Unexpected error from database adapter: `create` failed ("badConnection").  A connection either could not be obtained or there was an error using the connection.
Additional data:

{
  error: Error: self signed certificate in certificate chain
      at TLSSocket.onConnectSecure (_tls_wrap.js:1497:34)
      at TLSSocket.emit (events.js:315:20)
      at TLSSocket._finishInit (_tls_wrap.js:932:8)
      at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:706:12) {
    code: 'SELF_SIGNED_CERT_IN_CHAIN'
  },
8 replies
skyfall1970
@skyfall1970
when CSRF is enable(SocketServer),another project that how to pass csrf Token in Socket.io(SocketClient)?
Martin Barilík
@martinbarilik
Hi there, any idea why am i getting WebSocket connection to 'ws://{server-domain}/socket.io/?sails_io_sdk_version=1.1.0&sails_io_sdk_platform=node&__sails_io_sdk_language=javascript&EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 400 ? On devvelopment everything works just fine
usinng sails 0.12.x