Skip to content

Instantly share code, notes, and snippets.

View dclarke-modus's full-sized avatar

dclarke-modus

View GitHub Profile
//App.js
var React = require('react');
var CSSModules = require('react-css-modules');
var ReactRouter = require('react-router-dom');
var Router = ReactRouter.BrowserRouter;
var Route = ReactRouter.Route;
import styles from '../../../../sass/layout/_layout.scss';
var Index = require('../pages/Index');
var SideBar = require('../component/SideBar');
async getClient (clientId, clientSecret, callback) {
let client = await this.mongoClient.collection('client').findOne({"client" : clientId, "client_secret" : clientSecret}, {"_id" : 1});
let scopes = await this.mongoClient.collection('scope').find({"client_id" : client._id }).toArray();
console.log(scopes);
}
async getClient (clientId, clientSecret, callback) {
let client = await this.mongoClient.collection('client').findOne({"client" : clientId, "client_secret" : clientSecret}, {"_id" : 1});
let scopes = await this.mongoClient.collection('scope').find({"client_id" : client._id });
console.log(scopes.toArray());
}
/home/vagrant/api/node_modules/babel-core/lib/transformation/file/index.js:590
throw err;
^
SyntaxError: /home/vagrant/api/db/connection.js: Unexpected token (5:11)
3 |
4 | class ConnectionManager {
> 5 | protected mongoClient;
| ^
6 | constructor() {
*Code to save Client and Scope:*
```javascript
let scope = new ScopeModel();
scope.client = client._id;
scope.markModified('client');
console.log(scope);
await scope.save();
```
await connectionManager.connect();
let client = await connectionManager.getClient().findOne({'client' : 'local'});
let grant = await connectionManager.getGrant().findOne({'name' : 'Client_Credential'});
let service = await connectionManager.getService().findOne({'description' : 'Service 1'});
let ScopeModel = connectionManager.getScope();
let scope = new ScopeModel({client_id : client._id, grant_id : grant._id, service_id : service._id});
await scope.save();
console.log(await connectionManager.getClient().findOne({'client' : 'local'}).populate('scopes'));
id, name, age
1, dean, 10
2, dean, 10
1, blah, 9
table student table department
id, name, age id, name, student_id
1, dean, 10 1, Arts, 1
2, tah , 10
Table Students
id, name
1, Dean
2, Dean
3, Shahib
Table Students Table Class
id, name, class_id id, name
1, Dean, 1 1, Math
3, Shahib, 2 2, English
4, Chris, null 3, Science