Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
response = normalize(response, {
articles: arrayOf(article1)
});
}
}
// new Schema(key, [options])
const article2 = new Schema('articles');
// You can use a custom id attribute
const article3 = new Schema('articles', { idAttribute: 'slug' });
// Or you can specify a function to infer it
function generateSlug(entity: any) { /* ... */ }
const article4 = new Schema('articles', { idAttribute: generateSlug });
// Schema.prototype.define(nestedSchema)
const article5 = new Schema('articles');
const user5 = new Schema('users');
article5.define({
author: user5
});
// Schema.prototype.getKey()
const article6 = new Schema('articles');
article6.getKey();
// articles
};
// You can specify the name of the attribute that determines the schema
article9.define({
assets: arrayOf(asset9, { schemaAttribute: 'type' })
});
// Or you can specify a function to infer it
function inferSchema9(entity: any) { /* ... */ }
article9.define({
assets: arrayOf(asset9, { schemaAttribute: inferSchema9 })
});
// valuesOf(schema, [options])
const article10 = new Schema('articles');
const user10 = new Schema('users');
article10.define({
collaboratorsByRole: valuesOf(user10)
});
const article11 = new Schema('articles');
const user11 = new Schema('users');
const group11 = new Schema('groups');
const collaborator11 = {
users: user11,
groups: group11
};
// You can specify the name of the attribute that determines the schema
article11.define({
// users: {
// 7: { ... },
// ..
// }
// }
// }
response = normalize(response, {
articles: arrayOf(article1)
});
}
}
// new Schema(key, [options])
const article2 = new Schema('articles');
// You can use a custom id attribute
const article3 = new Schema('articles', { idAttribute: 'slug' });
// Or you can specify a function to infer it
function generateSlug(entity: any) { /* ... */ }
const article4 = new Schema('articles', { idAttribute: generateSlug });
// Schema.prototype.define(nestedSchema)
const article5 = new Schema('articles');
const user5 = new Schema('users');
article5.define({
author: user5
});
// }
// }
// }
response = normalize(response, {
articles: arrayOf(article1)
});
}
}
// new Schema(key, [options])
const article2 = new Schema('articles');
// You can use a custom id attribute
const article3 = new Schema('articles', { idAttribute: 'slug' });
// Or you can specify a function to infer it
function generateSlug(entity: any) { /* ... */ }
const article4 = new Schema('articles', { idAttribute: generateSlug });
// Schema.prototype.define(nestedSchema)
const article5 = new Schema('articles');
const user5 = new Schema('users');
article5.define({
author: user5
});
// Schema.prototype.getKey()
group12.define({
creator: unionOf(member12, { schemaAttribute: inferSchema })
});
const group13 = new Schema('groups');
const user13 = new Schema('users');
const member13 = unionOf({
users: user13,
groups: group13
}, { schemaAttribute: 'type' });
group13.define({
owner: member13,
members: arrayOf(member13),
relationships: valuesOf(member13)
});
// normalize(obj, schema, [options])
const article14 = new Schema('articles');
const user14 = new Schema('users');
article14.define({
author: user14,
contributors: arrayOf(user14),
meta: {
likes: arrayOf({
user: user14
})
}
});
const user11 = new Schema('users');
const group11 = new Schema('groups');
const collaborator11 = {
users: user11,
groups: group11
};
// You can specify the name of the attribute that determines the schema
article11.define({
collaboratorsByRole: valuesOf(collaborator11, { schemaAttribute: 'type' })
});
// Or you can specify a function to infer it
function inferSchema11(entity: any) { /* ... */ }
article11.define({
collaboratorsByRole: valuesOf(collaborator11, { schemaAttribute: inferSchema })
});
// unionOf(schemaMap, [options])
const group12 = new Schema('groups');
const user12 = new Schema('users');
// a member can be either a user or a group
const member12 = {
users: user12,
groups: group12
};
// You can specify the name of the attribute that determines the schema
group12.define({
owner: unionOf(member12, { schemaAttribute: 'type' })
assets: arrayOf(asset9, { schemaAttribute: 'type' })
});
// Or you can specify a function to infer it
function inferSchema9(entity: any) { /* ... */ }
article9.define({
assets: arrayOf(asset9, { schemaAttribute: inferSchema9 })
});
// valuesOf(schema, [options])
const article10 = new Schema('articles');
const user10 = new Schema('users');
article10.define({
collaboratorsByRole: valuesOf(user10)
});
const article11 = new Schema('articles');
const user11 = new Schema('users');
const group11 = new Schema('groups');
const collaborator11 = {
users: user11,
groups: group11
};
// You can specify the name of the attribute that determines the schema
article11.define({
collaboratorsByRole: valuesOf(collaborator11, { schemaAttribute: 'type' })
});
// Or you can specify a function to infer it
// @flow
import Normalizr from 'normalizr';
(Normalizr.normalize({ foo: '' }, {}): Object);
(Normalizr.normalize([{ foo: '' }], {}): Object);
(Normalizr.valuesOf({}): Normalizr$Schema);
// $ExpectError
(Normalizr.normalize(): Object);
// You can specify the name of the attribute that determines the schema
group12.define({
owner: unionOf(member12, { schemaAttribute: 'type' })
});
// Or you can specify a function to infer it
function inferSchema(entity: any) { /* ... */ }
group12.define({
creator: unionOf(member12, { schemaAttribute: inferSchema })
});
const group13 = new Schema('groups');
const user13 = new Schema('users');
const member13 = unionOf({
users: user13,
groups: group13
}, { schemaAttribute: 'type' });
group13.define({
owner: member13,
members: arrayOf(member13),
relationships: valuesOf(member13)
});
// normalize(obj, schema, [options])
const article14 = new Schema('articles');
const user14 = new Schema('users');
article14.define({
// a member can be either a user or a group
const member12 = {
users: user12,
groups: group12
};
// You can specify the name of the attribute that determines the schema
group12.define({
owner: unionOf(member12, { schemaAttribute: 'type' })
});
// Or you can specify a function to infer it
function inferSchema(entity: any) { /* ... */ }
group12.define({
creator: unionOf(member12, { schemaAttribute: inferSchema })
});
const group13 = new Schema('groups');
const user13 = new Schema('users');
const member13 = unionOf({
users: user13,
groups: group13
}, { schemaAttribute: 'type' });
group13.define({
owner: member13,
members: arrayOf(member13),
relationships: valuesOf(member13)
});