express

Using parses Facebook login api, results in current user null

非 Y 不嫁゛ 提交于 2020-01-14 13:37:11
问题 I am using parse to crate a simple demo site that allows users to login/signup using their Facebook account. the login returns success, i also get correct user name i also see the database get populated with the facebook acount data but back at app.js: Parse.User.current() is null Jvascript on client side (index.html) <script> // Initialize Parse Parse.initialize("zzzzzzzzzzzzzzzzzzzzz", "zzzzzzzzzzzzzzzzzzzzzzzz"); window.fbAsyncInit = function() { Parse.FacebookUtils.init({ // this line

How to filter array elements

浪子不回头ぞ 提交于 2020-01-14 12:53:51
问题 I have the following MongoDB document: { _id: ObjectId(5), items: [1,2,3,45,4,67,9,4] } I need to fetch that document with filtered items (1, 9, 4) result: { _id: ObjectId(5), items: [1,9,4] } I've tried an $elemMatch projection but it returns only one item: A.findById(ObjectId(5)) .select({ items: { $elemMatch: {$in: [1, 9, 4]}}}) .exec(function (err, docs) { console.log(doc); // { _id: ObjectId(5), items: [ 1 ] } done(err); }); How can I get the document with items: 1, 9, 4 only? 回答1: In

Error connecting to heroku postgres db in nodejs

时光总嘲笑我的痴心妄想 提交于 2020-01-14 12:53:09
问题 It seems after my database was upgraded to 10.2 I'm unable to connect. I'm using the pg 7.4.2 npm package. To be clear, I have been connecting without issue for 6 months using the same connection string which had ?ssl=true appended to it. I get this error connecting via Pool or Client. AssertionError [ERR_ASSERTION]: false == true at Object.exports.connect (_tls_wrap.js:1099:3) at Socket.<anonymous> (/home/e/express/testpg/node_modules/pg/lib/connection.js:94:23) at Object.onceWrapper (events

How to filter array elements

一笑奈何 提交于 2020-01-14 12:52:28
问题 I have the following MongoDB document: { _id: ObjectId(5), items: [1,2,3,45,4,67,9,4] } I need to fetch that document with filtered items (1, 9, 4) result: { _id: ObjectId(5), items: [1,9,4] } I've tried an $elemMatch projection but it returns only one item: A.findById(ObjectId(5)) .select({ items: { $elemMatch: {$in: [1, 9, 4]}}}) .exec(function (err, docs) { console.log(doc); // { _id: ObjectId(5), items: [ 1 ] } done(err); }); How can I get the document with items: 1, 9, 4 only? 回答1: In

Inheriting through Module.exports in node

假如想象 提交于 2020-01-14 12:49:07
问题 This is probably me being stupid... I'm using node with express and I have a seperate file using exports for routes. Above it, I require and cast to a variable, a package I have installed using npm. var passwordHash = require('password-hash'); app.get("/signup", routes.signup); inside routes.signup, I have: passwordHash.generate(req.form.username, {algorithm: 'sha512'}) and it throwing an error saying passwordHash is undefined. How can I go about "inheriting" said require call? 回答1: You can

Resolving nested data in express GraphQL

半世苍凉 提交于 2020-01-14 12:37:47
问题 I am currently trying to resolve a simple recipe list that has a reference to ingredients. The data layout looks like this: type Ingredient { name: String! amount: Int! unit: Unit! recipe: Recipe } type Recipe { id: Int! name: String! ingredients: [Ingredient]! steps: [String]! pictureUrl: String! } As I understand it, my resolvers should look like this: The first one resolves the recipes and second one resolves the ingredient field in the recipe. It can (from my understanding) use the

Users management in node js with express, mongodb as server database [closed]

自古美人都是妖i 提交于 2020-01-14 08:59:11
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . Looking for the way to add user management to my site. Site: Working with Node.js & Express, when creating the initial project with Express, the app.js file contains these lines: app.use('/', routes); app.use('/users', users); In addition, a file users.js is created under routes

I want to send data from many clients to one stable client using Node.js

狂风中的少年 提交于 2020-01-14 06:03:28
问题 Here is my code: var express = require('express'); var net = require('net'); var app = express(); //first of all connect to a stable client var server = net.createServer(function(socket) { // do nothing here . what i want is to use this socket in // (following) app.get() function }); server.listen(1337, '127.0.0.1'); //receive request from other clients app.get('/', function (req, res) { // retriving mobileNumber and message var mobileNumber = req.query.mobileNumber; var message = req.query

Problem coding a weak entity in sequelize

徘徊边缘 提交于 2020-01-14 06:00:51
问题 I am creating a cinema application. I have modeled the database on mySql but I am having trouble migrating it to Sequelize. I have followed the documentation but I am getting a lot of different errors. I have tried using associations and indexes (as it should be). This is the model I am trying to make. OCCUPIED_SEATS is composed of only two foreign keys and both make a unique index. OCCUPIED_SEATS : const SEATS = require("./Seats"); const SCREENING = require("./Screening"); const OCCUPIED

How to make API call using API token in Node.js using express, passport-local

时光怂恿深爱的人放手 提交于 2020-01-14 05:59:50
问题 I'm a newbie in Node.js and trying to use API token to access Grafana. And I created one API token by following instruction from Grafana page. However, I don't know how to make API calls from my code of node.js to access my local server of grafana page. Also, I have a local login-page by using mongoDB to manage users. How can I make Node.js API calls to access my local server of grafana page? Please help me out here.. I'm having hard time on this.. If you want me to show code, I can edit here