Table of Contents
Ok, so, you might know about JavaScript regular expressions. Well, here is a tutorial about them, but written by a 13 year old, so it isn't actually any good!
Regular expressions go between / characters. Here is an exampe, /hi/.
Ok, now then. Let's learn how to match the string abc. Well, that's quite simple.
/abc/. Yey! So putting letters next to each other makes them match one after the other.
Ok, now, after the second / we can put a g to make it match globally, that is, we can extract abc from xyzabcghi.
Ok, so, you might know about JavaScript regular expressions. Well, here is a tutorial about them, but written by a 13 year old, so it isn't actually any good!
Regular expressions go between / characters. Here is an exampe, /hi/.
Ok, now then. Let's learn how to match the string abc. Well, that's quite simple.
/abc/. Yey! So putting letters next to each other makes them match one after the other.
Ok, now, after the second / we can put a g to make it match globally, that is, we can extract abc from xyzabcghi.
When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).
When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.
Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.
So let's go through the one query that's worth memorizing to handle your eager loading.
| # Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands) | |
| gpg --gen-key | |
| # maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null` | |
| # check current keys: | |
| gpg --list-secret-keys --keyid-format LONG | |
| # See your gpg public key: | |
| gpg --armor --export YOUR_KEY_ID | |
| # YOUR_KEY_ID is the hash in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333) |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <stdint.h> | |
| #ifdef _MSC_VER | |
| #include <intrin.h> /* for rdtscp and clflush */ | |
| #pragma optimize("gt",on) | |
| #else | |
| #include <x86intrin.h> /* for rdtscp and clflush */ | |
| #endif |
| const { Model, AjvValidator } = require('objection'); | |
| const pluralize = require('pluralize'); | |
| class BaseModel extends Model { | |
| /** | |
| * Always use timestamps as default | |
| */ | |
| static get timestamps() { | |
| return true; | |
| } |
| import fs from 'fs' | |
| import { makeExecutableSchema } from 'graphql-tools' | |
| import { graphql } from 'graphql' | |
| // the actual resolvers | |
| import resolvers from '../src/resolvers' | |
| // the mock service | |
| import mockMovieService from './mocks/mockMovieService' | |
| // a nice structure for test cases | |
| // found at https://hackernoon.com/extensive-graphql-testing-57e8760f1c25 |
| 0.0.0.0 feedback.microsoft-hohm.com | |
| 0.0.0.0 search.msn.com | |
| 0.0.0.0 a.ads1.msn.com | |
| 0.0.0.0 a.ads2.msn.com | |
| 0.0.0.0 a.rad.msn.com | |
| 0.0.0.0 ac3.msn.com | |
| 0.0.0.0 ads.msn.com | |
| 0.0.0.0 ads1.msn.com | |
| 0.0.0.0 b.ads1.msn.com | |
| 0.0.0.0 b.rad.msn.com |