Skip to content

Instantly share code, notes, and snippets.

@c4software
Last active September 27, 2019 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c4software/30947f2a86eb0ab065d26a6ed0edb3e9 to your computer and use it in GitHub Desktop.
Save c4software/30947f2a86eb0ab065d26a6ed0edb3e9 to your computer and use it in GitHub Desktop.
DAO et Models d'exemple
// À mettre dans un dossier par exemple (models/utilisateur.js)
export default class Utilisateur {
nom = "";
prenom = "";
constructor(data) {
this.nom = data.nom;
this.prenom = data.prenom;
}
}
---
// À mettre dans un dossier par exemple (dao/utilisateur.js)
export default class UtilisateurDao {
static list() {
fetch("mon_lien/list"))
.then(function (response) {
return response.json();
}).then(function (data){
return data.map(it => new Utilisateur(it))
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment