Hi i removed waterline ORM from Sails JS and added mongoose, for that i followed the steps specified in the following link
http://laurentschaffner.com/blog/from-waterline-to-mongoose-in-sails/
But now am facing issues in installing sails-auth module can anyone help me out please.
I haven't tried to install sails-auth but I have successfully integrated Mongoose into Sails in a manner that I think is more friendly than the blog link you referenced. I created a gist here to help:
Gist: Adding Mongoose to Sails in a manner that binds promisified Mongoose functions to Model.mongoose, preserves blueprints (auto-generated action routes), and most importantly does not remove the Waterline ORM. Note: the code below uses ES2015 with the sails-babel hook.
https://gist.github.com/austinmao/83524cecd87ea1685b32
Related
I tried using new #apollo/server with NestJS instead of apollo-server-express. While using apollo-server-express, the apollo-server-core package is automatically used and no error is thrown. But when I remove apollo-server-express and install #apollo/server as dependency. There is the error.
Error: Cannot find module 'apollo-server-core'
Does anyone have any solution ??
There's no official support for Apollo Server v4 with #nestjs/graphql yet. You'd have to write a completely custom integration for that, or wait for this PR
A package for using Apollo Server 4 from NestJS is available here.
It works with both Express and Fastify.
I am learning backend with Node.js and using middleware to catch for errors and send a different response code and body.
The warning is similar to err.message.
How do I remove these warnings?
Are you using express? Its methods are generated dynamically in runtime, so they can't be resolved during static code analysis. Installing TypeScript stubs should help to get methods work: put cursor on 'express' in const express = require('express'); , hit Alt+Enter and choose Install TypeScript definitions for better type information to install typings - see https://www.jetbrains.com/help/webstorm/configuring-javascript-libraries.html#ws_jsconfigure_libraries_ts_definition_files
How can I access sequelize from other routes ?, all the tutorials I've seen use sequelize from app.js, but if I want to use a model from other route I'll need to initialize it everytime. how can I initialize sequelize globally and call it from other routes ?
Kenny, try to see this example from sequelize's site: Usage with Express.JS, it's very easy to understand, and the good thing is that using this approach you can singleton all your models, it load the models when starting the application and then use the require('models') to grab them all and use it everywhere you like (globally).
Hi I am making a Cordova app for iOS and Android. I am trying to use the cloudant module https://github.com/cloudant/nodejs-cloudant to access my cloudant couchDB, but for the life of me, I cannot figure out the issue I am having while installing it. Using linux, I executed npm install --save cloudant at the root of my Cordova project folder. When using var Cloudant = cordova.require('cloudant'); in my code, I get the error Uncaught module cloudant not found from within my cordova.js file as it tries to load the module. Also when I run $ node -e 'require("cloudant"); console.log("Cloudant works");' in my shell, I receive a terminal output stating "Cloudant works". I cannot seem to figure out what the issue is, and have tried many different things. Any help is extremely appreciated, as I am at my witts end at this point. Thanks.
As #Parth says, 'nodejs-cloudant' is a Node.js/npm module. To access Cloudant from within your Cordova application you will need client side code to interact with Cloudant's HTTP API.
You could use jQuery's Ajax functions to make HTTP requests to Cloudant or you can use PouchDB as a client-side library e.g:
<script src="pouchdb-3.4.0.min.js"></script>
<script>
var db = new PouchDB("https://myusername:mypassword#myaccount.cloudant.com/mydb";
</script>
Both solutions require you to enable CORS on your Cloudant account.
'nodejs-cloudant' is an npm module and not a cordova module. you just need to write
var Cloudant = require('cloudant'); That should solve the problem.
Try with this:
var Cloudant = require('cloudant');
Instead of importing cloudant directly, try using cradle or nano for accessing cloudant
'DB.const nano = require('nano')('//cloudant api link//');'
This works
https://www.npmjs.com/package/nano#dbinsertdoc-params-callback
https://www.npmjs.com/package/cradle
I should use a plugin named hapi-mongoose-db-connector into my hapijs application. In the repository page the developers suggest the ways you can import correctly it. It says that the following way is the bad way:
# from the server
mongoose = server.pack.plugins['hapi-mongoose-db-connector'].mongoose
# or from a plugin
mongoose = plugin.plugins['hapi-mongoose-db-connector'].mongoose
and discourages using it. Instead he recommends to do in the following way:
You do nothing and just require mongoose in your plugins. As npm
requires are singletons (the code is loaded only once this works very
well)
but he doesn't show any examples. At this point I'm not pretty sure how to use it. I wouldn't call in every js files mongoose. I would call it once in my application somewhere and in my js files where I create models for the database, use it. Do you know any best practices in those cases?
Actually, first one is the hapi way doing this kind of thing.
But as the mongoose module is a singleton, that plugin just require mongoose and initialize it [1] after load that plugin into hapi, you can use mongoose in any file;
var mongoose = require("mongoose");