Giter Club home page Giter Club logo

docs's People

Contributors

ad-si avatar arve0 avatar beeplin avatar bernardobelchior avatar bertho-zero avatar bravo-kernel avatar cdimitroulas avatar dekelev avatar eddyystop avatar jonsandg avatar marshallswain avatar nriesco avatar roikiermedia avatar sean-nicholas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

docs's Issues

Comment - Hooks - discard

Comment - Hooks - discard

For every item on the hooks common please indicate also what it should return.

Comment - Hooks - sifter

Comment - Hooks - sifter

The guide's spec table says "no" for "before" and "yes" for "after," but the example(s) contradict this showing the hook used as a before hook.

Comment - Hooks - skipRemainingHooks

Comment - Hooks - skipRemainingHooks

What does this warning/note mean?
! The database call itself will be shipped only if context.result has been set.

Is this referring to the fact that the service call is skipped if context.result is set? If so, then I propose this note is amended to read:
! The service call will only be skipped if context.result has been set manually.

Comment - Hooks - skipRemainingHooks

The API description is unclear.

  • How to properly use it in 'before' hooks to skip 'after' hooks?
  • There are numerous typos too. (content or context?) (skipRemainingHooks or shipRemainingHooks?)

Thank you!

Arrow is missing in getItems and replaceItems examples

const { getItems, replaceItems } = require('feathers-hooks-common');
const insertCode = code => context !!!=>!!! {
  const items = getItems(context);
  if (Array.isArray(items)) {
    items.forEach(item => { item.code = code; });
  } else {
    items.code = code;
  }
  replaceItems(context, items);
};
module.exports = { before: {
  create: insertCode('a')
} };

skipRemainingHooks not skipping before hooks with context.result set

The below skipRemainingHooks doesn't skip h:before checkRds()

context.result is set in the h:before checkSyn()
check.hooks.js

before: {
        create: [
            checkSyn(),
            (context) => {
                console.log('context.result %o', context.result);
            },
            skipRemainingHooks(),   // MUST, stop further h:b on Syn error
            checkRds()
        ],

console.log

context.result { SSyn: 1 }

Have tried unsuccessfully

skipRemainingHooks(context > context.result)
skipRemainingHooks((context) => { return true })

Is this the correct way to use the hook?

Comment - Hooks - mongoKeys

Missing closing tag around ObjectID in example

const { ObjectID = require('mongodb');

The documentation doesn't make it clear that this is only affects the query, and not data as well.

Comment - Hooks - actOnDefault

Hooks hook1, hook3 and hook5 will run “normally”, mutating content.result.
Hooks hook2 and hook4 will mutate context.dispatch.

Just pointing out a typo. I believe the bolded text in the above snippet from the docs should be
context.result

Discussion on feathers-hooks-common API format

@beeplin, I'm using a compacted version of the API format settled on for batch-loader API because I felt the size of feathers-hooks-common needed something that got the info across faster, terser.

Do you have the time to comment on it? Thanks.

Comment - Hooks - iff

Comment - Hooks - iff

I think we can add a .elseif, like .else.

I know it's possible, but for hooks to be indented as they would be with code it would be necessary to add this method.

iff(
  isAction('updateProfile'),
  /**/
).elseif(
  isAction('changePassword'),
  /**/
).else(
  /**/
)

instead of:

iff(
  isAction('updateProfile'),
  /**/
).else(
  iff(
    isAction('changePassword'),
    /**/
  )
  .else(
    /**/
  )
)

Comment - Hooks - iff

Comment - Hooks - iff
When returning SKIP from hook functions, it will throw 'method returned invalid hook object'

eg:

...
before:{
 find: [iff(isProvider('external'), async hook =>{
              hook.result = { code: 0 };
              return require('@feathersjs/feathers').SKIP;
          })]
}
...

Please advice

errors in browser console

client-bundle.js:74 Uncaught TypeError: Cannot set property 'feathersjs' of undefined
    at client-bundle.js:74
    at Object._typeof (client-bundle.js:77)
    at __webpack_require__ (client-bundle.js:20)
    at client-bundle.js:63
    at client-bundle.js:66
(anonymous) @ client-bundle.js:74
_typeof @ client-bundle.js:77
__webpack_require__ @ client-bundle.js:20
(anonymous) @ client-bundle.js:63
(anonymous) @ client-bundle.js:66
guide.html:383 GET http://localhost:4000/images/search.png 404 (Not Found)

Docs updates

This is a temperary dumping ground for docs updates I want to make for my various PRs

Feathers-vuex
feathersClient initAuth option - feathersjs-ecosystem/feathers-vuex#178
Typings - PR Incoming

include merging types of $FeathersVuex to include service typings and down sides to these typings

import { FeathersVuexGlobalModels } from "feathers-vuex";
import { Services } from "../store";

declare module "vue/types/vue" {
  interface Vue {
    $FeathersVuex: FeathersVuexGlobalModels<Services>;
  }
}

Comment - Hooks - stashBefore

Comment - Hooks - stashBefore
Perhaps a pedantic nitpick but this example imports "patch" but I think it meant to import "stashBefore".

const { patch } = require('feathers-hooks-common');
module.exports = { before: {
  patch: stashBefore()
} };

Comment - Hooks - preventChanges

Comment - Hooks - preventChanges
In the example it's show :

const { preventChanges } = require('feathers-hooks-common');
module.exports = { before: {
  patch: preventChanges(true, 'security.badge')
} };

But can i do this ? :

 const { preventChanges } = require('feathers-hooks-common');
 module.exports = { before: {
   patch: preventChanges(true, ['security.badge', 'anotherItem', 'anotherItem2'])
} };

Because i have got an error : Error: "path.split is not a function"

Comment - Hooks - required

Example shows

const { required } = require('feathers-hooks-common');
module.exports = { before: {
all: required('email', 'password')
} };

When it really only works for ['create', 'update', 'patch'].

Comment - Hooks - required

Comment - Hooks - required

I think some more info on how this works with find/get would be useful. Looking at the code it verifies that the property exists in the data object when patching/updating/creating but it is not clear how this would work on find/get. At first I assumed it would check the queries parameters but it seems like it still checks the data object, which to my knowledge has no use on the find/get hooks?

outdated jsonschema.net example

I would like to thank you for the great work with feathers-plus you took a great framework to a whole new level.
I'm new to JSON schema and jsonschema.net changed their design/options and I feel really lost any chance to update the docs with the new options or suggest good resources? then i will try to submit a PR with the update.

Comment - Hooks - fastJoin

Comment - Hooks - fastJoin

In the first example, where is users defined?

const postResolvers = {
  joins: {
    author: (...args) => async post => post.author = (await users.find({ query: {
      id: post.userId
    } }))[0],
    
    starers: $select => async post => post.starers = await users.find({ query: {
      id: { $in: post.starIds }, $select: $select || ['name']
    } }),
  }
};

Seems to be the case throughout the docs for fastJoin.

Also places where fastJoin(postResolvers, context => query)
Is it safe to assume that it should be fastJoin(postResolvers, context => context.params.query || query)?

Basic Guide: Document details of hook configuration

gr33nw00d [Yesterday at 6:27 PM]
in #help
My objective: I want my lastBeforeAllHook to be the last hook that runs before every service is called. I understand that before all hooks come before action-specific hooks, so a before.all hook will not work. Is there a more DRY way to accomplish this than registering the hook individually on all 6 actions? This hook specifically will be used on nearly every service, so as you can imagine it will be repeated many many times. (edited)

8 replies
daffl
[14 hours ago]
Register another before all hook after you registered the other ones.

app.service('myservice').hooks(fromhookFile).hooks({ before: afterBeforeAll })

daffl [14 hours ago]
You can also add it as a service mixin for all services by overriding setup:

  service.mixin({
    setup(... args) {
      this.hooks({ before: beforeAfterAll });
      return this._super(... args);
    }
  })
});

gr33nw00d [14 hours ago]
Don’t the hooks.before.all always run before anything in hooks.before.find ?

gr33nw00d [14 hours ago]
Or does it depend on the order of them being registered

daffl
[14 hours ago]
It depends on the order. In that case during setup all other hooks should be set up already

gr33nw00d [14 hours ago]
So what before.all really does is add the hook to some internal array for each action, as opposed to keep it in a separate beforeAll array

daffl [14 hours ago]
Yes

gr33nw00d [14 hours ago]
tyvm

Comment (Data Logically Removed After Update) - Hooks - softDelete2

Hello,

I want to ask why my data logically deleted after update using PUT.

My environment:

feathers-hook-common: 4.16.3
feathers-sequelize: 3.1.2
sequelize: 4.38.0

My model (just for example):

... // Any Data
text: Text
deleted: Boolean, allowNull: false, default: true
deletedAt: Date, allowNull: true

My services hooks:

const { softDelete2 } = require('feathers-hooks-common');

const optionsBefore = {
  deletedAt: 'deletedAt',
  keepOnCreate: true,
  skipProbeOnGet: false,
  allowIgnoreDeletedAt: true
};

const optionsAfter = {
  deletedAt: 'deletedAt',
  skipProbeOnGet: false,
  allowIgnoreDeletedAt: true
};

module.exports = {
  before: {
    all: [softDelete2(optionsBefore)],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  after: {
    all: [softDelete2(optionsAfter)],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  error: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  }
};

I try update spesific id using tools Postman,
My data like this:
PUT {host}/services/{id}

... (my data)
deleted: false

After I want update the data again, It return data logically deleted. Also when I update with deleted: 0.
When I send data within deletedAt: -1, also after I try to update data again, it return data logically deleted. Some my trial is:

  1. Make deleted: nullable
  • When send data without deleted, it will deleted logically too (because deleted becomes null)
  • When send data with deleted: true/0. It will deleted logically too.

Maybe I miss to how to use softDelete2()?

Updated:

After I read the source : https://github.com/feathers-plus/feathers-hooks-common/blob/b4adf36c61617e0e072a2e5c11de02ef83e44756/lib/services/soft-delete-2.js#L155

I think I miss the focus of softDelete2, It's different with softDelete() that checking delete data, the softDelete2() check deleteAt.

I want to change my question. If I use sequelize & MySQL,

  1. what type of data I should use (for deleteAt), should be STRING/TEXT?
  2. How I must send the data using REST so it will not deleted?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.