feathers-plus / docs Goto Github PK
View Code? Open in Web Editor NEWThe web site for Feathers-Plus. http://feathers-plus.github.io
License: Other
The web site for Feathers-Plus. http://feathers-plus.github.io
License: Other
feathersjs-ecosystem/feathers-vuex#197 (comment)
The linked PR added a toJSON method to the feathersVuexModels. With this change getters (for example from instanceDefaults
) are included in the serialized result. We should add some documentation about setting the instance defaults tohave enumerable: false
set if those values shouldn't be serialized.
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.
I found that these link return an 404 Page Not found error on the doc site:
Thank to fix them.
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?
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 - Hooks - discardQuery
Example provided is an after
hook but discardQuery
is a before
hook.
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
Example shows
const { required } = require('feathers-hooks-common');
module.exports = { before: {
all: required('email', 'password')
} };
When it really only works for ['create', 'update', 'patch'].
@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.
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
link for produced a GraphQL example on page https://generator.feathers-plus.com/get-started/#graphql is incorrect and should be the link below
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 - 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()
} };
Kinda self explanatory, at the moment it only says that you can pass a clone function in options, but says nothing about makeCacheKey. Took some hard time finding out about it. (:
Comment - Hooks - validate
Hi,
I've noted that the guide section with validation examples (https://feathers-plus.github.io/v1/feathers-hooks-common/guide.html#Validate) includes an example of validation with another package (https://github.com/eddyystop/feathers-hooks-validate-joi), I first tought that it used validateSchema from this project but it was wrong, validateSchema from this project uses ajv.
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')
} };
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)
?
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>;
}
}
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)
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 - 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.
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:
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,
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"
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?
In the example here:
https://feathers-plus.github.io/v1/feathers-hooks-common/guide.html#Validation-using-Validate
The docs still make use of the remove method in the feathers-common-hooks package. The docs should be updated to use the favored discard method.
The API description is unclear.
Thank you!
Comment - Hooks - discard
For every item on the hooks common please indicate also what it should return.
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(
/**/
)
)
Read the guide for more information on the arguments.
link is broken
Comment - Hooks - disableMultiItemChange
The documentation doesn't mention the type of error that is thrown by this hook.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.