mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core: user: private and public projection (#507)
This commit is contained in:
1 parent
4fe734a6f3
commit
bd13c57d82
6 files changed
+44
-26
No files matched your search
@@ -0,0 +1,16 @@
|
||||
interface SerializeOptions {
|
||||
showDisplayName: boolean;
|
||||
currentSerializer?: (k: string, v: any) => any;
|
||||
}
|
||||
|
||||
export default function serializer(options: SerializeOptions, ignoreSerializeFunction = false) {
|
||||
options.currentSerializer = (k: string, v: any) => {
|
||||
if (typeof k.startsWith !== 'function') console.log(k, v);
|
||||
if (k.startsWith('_') && k !== '_id') return undefined;
|
||||
if (typeof v === 'bigint') return `BigInt::${v.toString()}`;
|
||||
if (!ignoreSerializeFunction && v && typeof v === 'object'
|
||||
&& 'serialize' in v && typeof v.serialize === 'function') return v.serialize(options);
|
||||
return v;
|
||||
};
|
||||
return options.currentSerializer;
|
||||
}
|
||||
Reference in new issue
Block a user