Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
gcloud-datastore-schema
Advanced tools
Define and follow a schema for your Datastore entities
$ npm install --save gcloud-datastore-schema
var gcloud = require('gcloud');
var schema = require('gcloud-datastore-schema');
var datastore = schema(gcloud.datastore({/*...*/}));
// New method: register
datastore.register('Person', {
// Native JavaScript types
name: String,
age: Number,
tools: Array,
favoriteNumbers: [Number],
isPremiumUser: Boolean,
// Datastore types
gpa: gcloud.datastore.double,
// Nested schemas
address: {
streetNumber: Number,
streetName: String,
// Nested nested schemas
zip: {
firstPart: Number,
secondPart: Number
}
},
// Nested array schemas
phoneNumbers: [
{
number: String,
metadata: {
type: String,
// Nested nested array schemas
availability: [
String
]
}
}
],
// Custom validators
fullName: function (input) {
return input.split(' ').length > 1;
}
});
// The original save method will now validate by default
// So let's make it mad
datastore.save({
key: datastore.key(['Person']),
data: {
name: 'Doc',
age: 8,
tools: ['Stethoscope', 'Positive attitude'],
favoriteNumbers: [16, 91],
gpa: gcloud.datastore.int(4.0),
address: {
streetNumber: 123,
streetName: 'Main',
zip: {
firstPart: 12345,
secondPart: 4444
}
},
phoneNumbers: [
{
number: '555-1212',
metadata: {
availability: [
'9-5',
95
]
}
}
],
fullName: 'Doc',
extraData: true,
extraExtraData: false
}
}, function (err) {
// err:
// {
// code: 'ESCHEMAVIOLATION',
// message: 'Schema validation failed',
// errors: [
// {
// kind: 'Person',
// errors: [
// 'Schema definition expected property: "isPremiumUser"',
// 'Schema definition violated for property: "gpa". Expected type: Double, received: Int',
// 'Schema definition expected property: "phoneNumbers[].metadata.type"',
// 'Schema definition violated for property: "phoneNumbers[].metadata.availability[].availability". Expected type: String, received: 95',
// 'Schema definition violated for property: "fullName"',
// 'Unexpected properties found: "extraData", "extraExtraData"'
// ]
// }
// ]
// }
})
Coming soon, sorry. For now, please use the above example as a guide.
FAQs
Define and follow a schema for your Datastore entities
The npm package gcloud-datastore-schema receives a total of 0 weekly downloads. As such, gcloud-datastore-schema popularity was classified as not popular.
We found that gcloud-datastore-schema demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.