Typescript

npm install --save @types/google-cloud__datastoreLast updated
Was this helpful?

npm install --save @types/google-cloud__datastoreLast updated
Was this helpful?
Was this helpful?
// user.schema.ts
import GstoreNode from 'gstore-node';
const gstore = GstoreNode();
type UserType = {
userName: string;
email: string;
age?: number; // optional
tags?: string[]; // optional
birthday?: Date; // optional
}
// Pass it on Schema creation
const schema = new Schema<UserType>({
userName: { type: String },
email: { type: String },
age: { type: Number, optional: true },
tags: { type: Array, optional: true },
birthday: { type: Date, optional: true }
});
// Pass it on Model creation
const User = gstore.model<UserType>('User', schema);type UserType = {
userName: string;
email: string;
age?: number; // optional
tags?: string[]; // optional
birthday?: Date; // optional
} & {[propName: string]: any}; // Allow any other properties
// Schema with "explicitOnly" set to "false"
const schema = new Schema<UserType>({
userName: { type: String },
email: { type: String },
age: { type: Number, optional: true },
tags: { type: Array, optional: true },
birthday: { type: Date, optional: true }
}, { explicitOnly: false }); // explicitOnly set to "false"
const User = gstore.model<UserType>('User', schema);