Practical No.
: 1
Aim: Write a program to implement MongoDB data models.
Date: Roll No:17 Sign:
Program:
[Link]
const mongoose = require("mongoose");
[Link]('strictQuery' , true);
[Link]("mongodb://localhost:27017" , [Link]('Connected to Database'));
//Creating Schema
const studentSchema = new [Link]({Name : String , Roll_No : Number , Class :
String , Age : Number , Email : String})
//Defining Student Model
const Student = [Link]('Student' , studentSchema);
//Create Collection of Model
[Link]().then(function(){
[Link]('Collection is Created !');
});
Output:
[Link]
const mongoose = require("mongoose");
//Schema for Collection
const studentSchema = new [Link]({Name : String , Roll_No : Number , Class :
String , Contact_No : String , Age : Number ,
Email : String},{collection : "students"});
//Exporting Scheme
[Link] = [Link]("student" , studentSchema);
Output:
Practical No.: 2
Aim: Write a program to implement CRUD operations on MongoDB
Date: Roll No:17 Sign:
Program:
[Link]
const mongoose=require('mongoose');
[Link]('strictQuery',true);
[Link]('mongodb://[Link]:27017',{
dbName:"test",useUnifiedTopology:true,useNewUrlParser:true
},err=>err? console:log(err),[Link]("Connected to database"));
const studentSchema= new [Link](
{
name:String,
rollNo:Number,
class:String,
age:Number,
email:String
}
)
const Student = [Link]("Student",studentSchema);
var db = [Link];
[Link]().then(function(){
[Link]('Collection is created');
});
[Link]('error',[Link](console,'connection error'));
Output:
[Link]
const mongoose=require('mongoose');
[Link]('strictQuery',true);
[Link]('mongodb://[Link]:27017',[Link]("Connected to database"));
const studentSchema= new [Link](
{
name:String,
rollNo:Number,
class:String,
age:Number,
email:String
}
)
const Student = [Link]("Student",studentSchema);
var db = [Link];
var student1 = new Student({name:"Lalit Rawool",
rollNo:10,
class:"SyCs",
age:19,
email:"lalitrawool25@[Link]"});
[Link](function(err,result){
if(err){
[Link](err);
}else{
[Link](result);
}
})
Output:
[Link]
const mongoose = require('mongoose');
var db = [Link];
[Link]('strictQuery',true);
[Link]('mongodb://[Link]:27017',{
dbName:"test",useUnifiedTopology:true,useNewUrlParser:true
},err=>err? [Link](err):[Link]("Connected to database"))
const studentSchema = new [Link](
{
name:String,
rollNo:Number,
class:String,
age:Number,
email:String
}
)
const Student = [Link]("Student",studentSchema);
[Link]('open',function(){
[Link]([{name:"Rohit Rawool",
rollNo:11,
class:"Baf",
age:20,
email:"rohit@[Link]"},
{name:"Shravani Rawool",
rollNo:1,
class:"BSc",
age:23,
email:"shravani@[Link]"},
{name:"Saurabh Rawool",
rollNo:5,
class:"BCS",
age:23,
email:"saurabh@[Link]"}]).then(function(){
[Link]('data inserted');
}).catch(function(err){
[Link](err);
})
})
Output:
[Link] a record into the collection.
[Link]
const mongoose = require('mongoose');
[Link]('strictQuery',true);
[Link]('mongodb://localhost:27017',{
dbName:"test",useUnifiedTopology:true,useNewUrlParser:true
},err=>err? [Link](err):[Link]("Connected to database"))
const studentSchema = new [Link](
{
name:String,
rollNo:Number,
class:String,
age:Number,
email:String
}
)
const Student = [Link]("Student",studentSchema);
var db = [Link];
var student1 = new Student({name:"swapnali rane",
rollNo:10,
class:"SyCs",
age:19,
email:"SwapnaliRane123@[Link]"});
[Link]({name:"swapnali rane"},{name:"Rakhi"},function(err,result){
if(err){
[Link](err);
}else{
[Link](result);
}
}
);
Output:
5. Fetch and Get all the records
[Link]
Source code:
const mongoose=require('mongoose');
[Link]('strictQuery',true);
[Link]('mongodb://localhost:27017',
[Link]("Connected to database"))
const studentSchema=new [Link](
{
name:String,
rollNo:Number,
class:String,
age:Number,
email:String,
}
)
const Student=[Link]("Student",studentSchema);
var db=[Link];
[Link]({}).then(data=>{
[Link]('Data:');
[Link](data);
}).catch(error=>{
[Link](error);
})
Output:
Practical No.:03
Aim: Write a program to perform validation of a form using AngularJS.
Date: Roll No.:17 Sign:
____________________________________________________________________________
[Link] [Link]
Source code:
<!DOCTYPE html>
<html>
<head>
<title>AngularJs Form Input Fields Validation Example</title>
<script src="[Link]
<script>
var app = [Link]('formApp', []);
[Link]('formCtrl', function ($scope)
{
$[Link] = function ()
{
$[Link]='Form Submited Successfully';
};
$[Link] = function (color)
{
return [Link]();
}
});
</script>
<style>
.[Link]
{
background: red;
}
.[Link]
{
background:green;
}
.error
{
color: red;
}
</style>
</head>
<body ng-app="formApp" ng-controller="formCtrl">
<h3>Form validation demo app in AngularJs</h3>
<form name="personForm" ng-submit="sendForm()">
<label for="name">Name</label>
<input id="name" name="name" type="text" ng-model="[Link]" required />
<span class="error" ng-show="[Link].$[Link]"> Required! </span>
<br /><br />
<label for="adress">Adress</label>
<input id="address" name="address" type="text" ng-model="[Link]"
required />
<span class="error" ng-show="[Link].$[Link]"> Required!
</span>
<br /><br />
<label for="contact">Contact No</label>
<input id="mobile" name="mobile" type="number" ng-model="[Link]"
required />
<span class="error" ng-show="[Link].$[Link]">Required number!
</span>
<span class="error" ng-show="[Link].$[Link]">Invalid
mobile!</span>
<br /><br />
<label for="email">Email</label>
<input id="email" name="email" type="email" ng-model="[Link]" required />
<span class="error" ng-show="[Link].$[Link]">Required!</span>
<span class="error" ng-show="[Link].$[Link]">Invalid Email!</span>
<br /><br />
<input type="checkbox" ng-model="terms" name="terms" id="terms" required />
<label for="terms">I Agree to the terms.</label>
<span class="error" ng-show="[Link].$[Link]">You must agree to
the terms</span>
<br /><br />
<button type="submit">Submit Form</button>
<br /><br />
<span>{{msg}}</span>
</form>
</body>
</html>
[Link]
<!DOCTYPE html>
<html>
<head>
<title>Welcome Page</title>
</head>
<body bgcolor="yellow">
<h1>Record Successfully Submitted........</h1>
</body>
</html>
Output:
Practical No.:04
Aim: Write a program to create and implement modules and controllers in AngularJS?
Date: Roll No.:17 Sign:
____________________________________________________________________________
[Link]:
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf 8">
<title>Angular First App</title>
</head>
<body>
<h1 ng-controller="HelloWorldCtrl">Name:{{Name}}</h1>
<h1 ng-controller="HelloWorldCtrl">Website:{{Website}}</h1>
<script src="[Link]
<script>
[Link]("app", []).controller("HelloWorldCtrl", function($scope) {
$[Link] = " Kankavli College Kankavli ";
$[Link] = "[Link]";
})
</script>
</body>
</html>
Output:
Practical No.:05
Aim:Create an application for customer/students records using AngularJS.
Date: Roll No.:17 Sign:
____________________________________________________________________________
[Link]
Source code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Angular Js Module</title>
<script src="[Link]
<script src="[Link]"></script>
<script src="[Link]"></script>
<style>
table,th,td{
border: 1px solid gray;
border-collapse: collapse;
padding: 5px;
}
table tr:nth-child(odd){
background-color: #f2f2f2;
}
table tr:nth-child(even){
background-color: #ffffff;
}
</style>
</head>
<body ng-app="mainApp">
<h2>AngularJS Sample Application</h2>
<div ng-controller="studentController">
<table border="0">
<tr>
<td>Enter First Name : </td>
<td><input type="text" ng-model="[Link]"></td>
</tr>
<tr>
<td>Enter Last Name : </td>
<td><input type="text" ng-model="[Link]"></td>
</tr>
<tr>
<td>Name: </td>
<td>{{[Link]()}}</td>
</tr>
<tr>
<td>Subject:</td>
<td>
<table>
<tr>
<th>Name</th>
<th>Marks</th>
</tr>
<tr ng-repeat="subject in [Link]">
<td>{{[Link]}}</td>
<td>{{[Link]}}</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
[Link]
var mainApp = [Link]("mainApp", []);
[Link]:
Source code:
[Link]("studentController", function($scope) {
$[Link] = {
firstName: "Sanika",
lastName: "Thakare",
fees:500,
subjects:[
{name:'Physics',marks:70},
{name:'Chemistry',marks:80},
{name:'Math',marks:65},
{name:'English',marks:75},
{name:'Hindi',marks:67}
],
fullName: function() {
var studentObject;
studentObject = $[Link];
return [Link] + " " + [Link];
}
};
});
Output:
Practical No.:06
Aim: Create a simple HTML “Hello World” Project using AngularJS Framework and apply
ng-controller, ng-model and expressions
Date: Roll No.:17 Sign:
___________________________________________________________________
[Link]
Program:
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf 8">
<title>Angular First App</title>
</head>
<body>
<h1 ng-controller="HelloWorldCtrl">{{message}}</h1>
<script src="[Link]
<script>
[Link]("app", []).controller("HelloWorldCtrl", function($scope) {
$[Link]="Hello World!!!"
})
</script>
</body>
</html>
Output:
Practical No.:07
Aim: Create an app using Flutter for User Authentication
Date: Roll No.:17 Sign:
_____________________________________________________________________
[Link]
Program:
import 'package:flutter/[Link]';
import '[Link]';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: LoginDemo(),
);
}
}
class LoginDemo extends StatefulWidget {
@override
_LoginDemoState createState() => _LoginDemoState();
}
class _LoginDemoState extends State<LoginDemo> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: [Link],
appBar: AppBar(
title: Text("Login Page"),
),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Padding(
padding: const [Link](top: 60.0),
child: Center(
child: Container(
width: 200,
height: 150,
/*decoration: BoxDecoration(
color: [Link],
borderRadius: [Link](50.0)),*/
child: [Link]('asset/images/[Link]')),
),
),
Padding(
//padding: const [Link](left:15.0,right: 15.0,top:0,bottom: 0),
padding: [Link](horizontal: 15),
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Email',
hintText: 'Enter valid email id as abc@[Link]'),
),
),
Padding(
padding: const [Link](
left: 15.0, right: 15.0, top: 15, bottom: 0),
//padding: [Link](horizontal: 15),
child: TextField(
obscureText: true,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Password',
hintText: 'Enter secure password'),
),
),
TextButton(
onPressed: (){
//TODO FORGOT PASSWORD SCREEN GOES HERE
},
child: Text(
'Forgot Password',
style: TextStyle(color: [Link], fontSize: 15),
),
),
Container(
height: 50,
width: 250,
decoration: BoxDecoration(
color: [Link], borderRadius: [Link](20)),
child: TextButton(
onPressed: () {
[Link](
context, MaterialPageRoute(builder: (_) => HomePage()));
},
child: Text(
'Login',
style: TextStyle(color: [Link], fontSize: 25),
),
),
),
SizedBox(
height: 130,
),
Text('New User? Create Account')
],
),
),
);
}
}
[Link]:
Source code:
import 'package:flutter/[Link]';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Home Page'),
),
body: Center(
child: Container(
height: 80,
width: 150,
decoration: BoxDecoration(
color: [Link], borderRadius: [Link](10)),
child: TextButton(
onPressed: () {
[Link](context);
},
child: Text(
'Welcome',
style: TextStyle(color: [Link], fontSize: 25),
),
),
),
),
);
}
}
Change in [Link]:
uses-material-design: true
assets:
-assets/asset/images/[Link]
Output:
Before:
After click on login:
Practical No.:08
Aim:
Date: Roll No.:17 Sign:
____________________________________________________________________________
[Link]
Source code:
name: gallery
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: '>=2.19.6 <3.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
cached_network_image: ^3.2.3
photo_view: ^0.14.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
[Link]
import 'package:flutter/[Link]';
import 'package:gallery/gallery_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({[Link]});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: [Link],
appBarTheme: const AppBarTheme(centerTitle: true),
),
home: GalleryPage(),
);
}
}
gallery_page.dart:
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/[Link]';
import 'package:gallery/photo_view_page.dart';
class GalleryPage extends StatelessWidget {
GalleryPage({Key? key}) : super(key: key);
final List<String> photos = [
'[Link]
'[Link]
mp_Tibet_Luca_Galuzzi_2006.jpg',
'[Link]
q=tbn:ANd9GcRMfWrZ_y19LrYRtNno1Oxs4pvB7TxLG3ELcQ&usqp=CAU/[Link]',
'[Link]
'[Link]
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Gallery")),
body: [Link](
physics: const BouncingScrollPhysics(
parent: AlwaysScrollableScrollPhysics(),
),
padding: const [Link](1),
itemCount: [Link],
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
),
itemBuilder: ((context, index) {
return Container(
padding: const [Link](0.5),
child: InkWell(
onTap: () => [Link](
context,
MaterialPageRoute(
builder: (_) => PhotoViewPage(photos: photos, index: index),
),
),
child: Hero(
tag: photos[index],
child: CachedNetworkImage(
imageUrl: photos[index],
fit: [Link],
placeholder: (context, url) => Container(color: [Link]),
errorWidget: (context, url, error) => Container(
color: [Link].shade400,
),
),
),
),
);
}),
),
);
}
}
photo_view_page.dart:
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/[Link]';
import 'package:photo_view/photo_view.dart';
import 'package:photo_view/photo_view_gallery.dart';
class PhotoViewPage extends StatelessWidget {
final List<String> photos;
final int index;
const PhotoViewPage({
Key? key,
required [Link],
required [Link],
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
backgroundColor: [Link],
elevation: 0,
),
body: [Link](
itemCount: [Link],
builder: (context, index) => [Link](
child: CachedNetworkImage(
imageUrl: photos[index],
placeholder: (context, url) => Container(
color: [Link],
),
errorWidget: (context, url, error) => Container(
color: [Link].shade400,
),
),
minScale: [Link],
heroAttributes: PhotoViewHeroAttributes(tag: photos[index]),
),
pageController: PageController(initialPage: index),
enableRotation: true,
),
);
}
}
Output:
Zoom image: